jest-circus async tests#3819
Conversation
b629332 to
cbd70ce
Compare
cbd70ce to
09a8561
Compare
| global.fit = global.it.only; | ||
| global.fdescribe = global.describe.only; | ||
|
|
||
| global.test.concurrent = ( |
There was a problem hiding this comment.
i'm not including test.concurrent into jest-circus as a core functionality. In the current state it's never going to work properly (can't use certain matchers/hooks/proper .skip/.only/etc).
I also think we shouldn't document it either. It will be harder to reimplement it properly in the future if people start using it
There was a problem hiding this comment.
we could actually make a breaking change to test.concurrent to pass the context as first argument (rather than "done") like we were planning to do, that way we could make it work properly with state.
There was a problem hiding this comment.
there's too many changes that need to be made before we can do that.
it's easier to keep it as it is right now and we'll focus on redesigning it later
|
|
||
| export type TestStatus = 'pass' | 'fail' | 'skip'; | ||
| export type TestStatus = 'skip' | 'done'; | ||
| export type TestResult = {| |
There was a problem hiding this comment.
i removed fail status, since it's a derived value that can be calculated from test.errors.length.
All we need to know is whether it was skipped or finished running
There was a problem hiding this comment.
how about 'skip' | 'complete' then? Any other words instead of 'done'?
| beforeAll(() => { | ||
| return new Promise(resolve => setTimeout(resolve, 100)); | ||
| }, 10); | ||
| }, 11); |
There was a problem hiding this comment.
easier to find in the console :)
|
|
||
| 'use strict'; | ||
|
|
||
| const testEventHandler = (event, state) => { |
There was a problem hiding this comment.
This is really nice, I love how you are testing this. Could we make it a bit more generic somehow so that we don't have to keep this file in sync, though?
| const TEST_EVENT_HANDLER_PATH = path.resolve(__dirname, './test_event_handler'); | ||
|
|
||
| const runTest = (source: string) => { | ||
| const tmpFilename = path.join(os.tmpdir(), 'circus-test-file.js'); |
There was a problem hiding this comment.
this is the safest, but not the most pleasant way of writing files.
I was thinking about creating a gitignored directory (files_for_integration_tests) and write everything there, so it's easy to cd into the dir and see what's up in there
| `"currentDescribeBlock" has to be there since we're finishing its definition.`, | ||
| ); | ||
| } | ||
| invariant(currentDescribeBlock, `currentDescribeBlock mest to be there`); |
There was a problem hiding this comment.
i think it's something in between jest, must and has. i can't spell :'(
| const {currentDescribeBlock} = state; | ||
| const {fn, hookType: type} = event; | ||
| currentDescribeBlock.hooks.push({fn, type}); | ||
| const {fn, hookType: type, timeout} = event; |
There was a problem hiding this comment.
I'm not sure I like the aliasing. Why do we need to rename hookType to type?
rogeliog
left a comment
There was a problem hiding this comment.
It looks really good overall, just some small comments
| @@ -0,0 +1,75 @@ | |||
| /** | |||
| const {type} = hook; | ||
|
|
||
| if (type === 'beforeAll') { | ||
| invariant(describeBlock, 'always present for `*All` hooks'); |
There was a problem hiding this comment.
I think we need to add a prefix to the message? Similar to the contentBlock invariant message
| // too complicated, so we'll consider them to be global. | ||
| state.unhandledErrors.push(error); | ||
| } else { | ||
| invariant(test, 'always present for `*Each` hooks'); |
There was a problem hiding this comment.
I think we need to add a prefix to the message? Similar to the contentBlock invariant message
| break; | ||
| } | ||
| case 'test_failure': { | ||
| event.test.status = 'fail'; |
There was a problem hiding this comment.
Do we not need the fail status anymore?
|
|
||
| const test = (testName: TestName, fn?: TestFn) => | ||
| dispatch({fn, name: 'add_test', testName}); | ||
| const test = (testName: TestName, fn?: TestFn, timeout?: number) => |
There was a problem hiding this comment.
NIT: line 37 uses timeout: ?number instead of timeout?: number
There was a problem hiding this comment.
that's expected though! :)
in this function timeout is optional, and on line37, it's always passed, but can be null
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
makes
integration_tests/__tests__/jasmine_async-test.jspass.jest-circusin isolationtest/*Each/*Allas a last argument