-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement test and fixture modifiers #1107
Conversation
❌ Tests for the commit cea63e1 have failed. See details: |
❌ Tests for the commit 3ebb00c have failed. See details: |
❌ Tests for the commit acc4799 have failed. See details: |
❌ Tests for the commit 4545474 have failed. See details: |
✅ Tests for the commit 1c44154 have passed. See details: |
❌ Tests for the commit 84c88a2 have failed. See details: |
❌ Tests for the commit 42969f8 have failed. See details: |
❌ Tests for the commit 0303e8d have failed. See details: |
❌ Tests for the commit f62d05e have failed. See details: |
✅ Tests for the commit f62d05e have passed. See details: |
6b59c21
to
874487a
Compare
✅ Tests for the commit 874487a have passed. See details: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
✅ Tests for the commit 0565d2d have passed. See details: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Let's add in documentation example for skip
and only
in different style of fixture implementations:
fixture( fixtureName )
fixture `fixtureName`
I feel like it can be excessive. Test runs are our internal stuff. We should just say: "Your test needs some initialization code? Put it here!", And it is our job to ensure that it runs in every browser. Users shouldn't bother. |
* Implement test.only and fixture.only * Move logic for test.only filtering to bootstrapper. * Implement test.skip and fixture.skip * Add tests for test.skip * Fix test error. Implement test.page. Refactor. * Fix raw API. * Add test for test.page * Implement test.before and test.after hooks * Fix tests * Tests for test.before and test.after * Implement test.httpAuth. Add tests for test.before and test.after args * Test test.httpAuth. Fix compiler test file heuristics * Implement t.ctx * Make t.ctx assignable * Fix compiler filter RegExps
Features summary
test.only, test.skip, fixture.only, fixture.skip (closes #246)
You can now skip specific fixtures or tests using
.skip
modifier. In contrast, you can run only specified tests or fixtures using.only
directive..skip
example:.only
example:Note that reporter plugin now accepts additional
skipped
field in testRunInfo object, thus plugin now can decorate skipped tests in the distinct manner. All built-in reporters and plugin generator were updated to support this feature.test.before and test.after hooks (closes #1108)
Test now supports
test.before
andtest.after
hooks that behave the same way as fixture.beforeEach and fixture.afterEach hooks with the exception that hook will run only for the specified test. Iffixture.beforeEach
andfixture.afterEach
hooks are specified as well, test-specific hook will override them.Example:
Note for tech writers: Current fixture.beforeEach and fixture.afterEach hooks section in documentation is not quite accurate. It's worth mentioning that hooks are run for each test run of the given test. So e.g., if we have 3 browsers set for the test run, each hook will be executed in each browser right before and after the test.
t.ctx object (closes #841)
t.ctx
is an object that is shared betweenfixture.beforeEach
,fixture.afterEach
,test.before
,test.after
hooks and test itself. Each test run has it's ownt.ctx
object. This object can be used to share variables and other test-specific stuff between test functions without introducing global variables (it's even more complicated in TestCafe since single test can be run in several browsers).Example:
By default
t.ctx
is initialized to empty object without prototype (so it's safe to iterate its keys withouthasOwnProperty
check). However, you can assign anything tot.ctx
and assigned value will be shared, e.g.:test.page directive (closes #501)
You can now specify startup page for the particular test that will override page specified for the fixture. It was possible previously to navigate to the specific page in the test by calling
t.navigateTo
, but it had a drawback that test first navigated to the page specified for the fixture. Additional navigation now avoidable withtest.page
directive.Example:
test.httpAuth directive (closes #1109)
In addition to newly introduced HTTP authentication feature (#955) it's now possible to specify authentication credentials for particular test. If credentials are specified for fixture as well, they will be overridden by test-specific credentials.
Example:
Note that you can specify fixture and test directives before and after declarations, so all this cases are valid:
\cc @helen-dikareva @AlexanderMoskovkin @churkin @AndreyBelym @lexkazakov @VasilyStrelyaev