HuddleEng / PhantomFlow

Describe and visualise user flows through tests with PhantomJS
MIT License
682 stars 60 forks source link

Test should fail when targeted element doesn't exist #12

Closed NiGhTTraX closed 10 years ago

NiGhTTraX commented 10 years ago

Problem

-$ node tests/visual/runner.js test=foo
Parallelising 1 test files on 1 threads.

TESTFILE foo.test.js

~ Phantom Flow.  Running all paths for: default

~ default

~ initial

return diffile

[PhantomCSS] Screenshot capture failed:  No element matching selector found: #foo

TESTFILE PhantomCSS

 There are 0 visual tests to check

<testsuite name="[foo.test.js] default" tests="0" failures="0">
</testsuite>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
JUnit output: No test cases for foo.test.js

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Fini.

 All the threads have completed.

Completed 0 tests in 3 seconds. 0 failed, 0 passed.
-$ echo $?
0

Need

As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then the test should fail
And an error should be thrown informing me about the guilty selector
So that I'm aware that my code doesn't work as expected.

Deliverables

As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then the test should fail
So that I'm aware that something is wrong with my code.
As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then an error should be thrown informing me about the guilty selector
So that I'm aware of what went wrong.
As a developer
Given that I run a PhantomFlow test
And the element I'm trying to take a screenshot of doesn't exist
Then a non-zero exit code should be returned
So my tasks can fail.
jamescryer commented 10 years ago
Flow: "As a developer using PhantomFlow"
  Step: "Run test"
  Chance: "Screenshot element doesn't exist"
    Step: "Read reported error"
    Step: "See that test suite has failed"

Thanks for the Pull request. I have made a slight change.

NiGhTTraX commented 10 years ago

@jamescryer awesome! Can you also bump the npm package?

jamescryer commented 10 years ago

Done.