99
1010import type {
1111 RunResult ,
12- TestEntry ,
13- TestContext ,
14- Hook ,
15- DescribeBlock ,
12+ TestEntry ,
13+ TestContext ,
14+ Hook ,
15+ DescribeBlock ,
1616} from 'types/Circus' ;
1717
18- import { getState , dispatch } from './state' ;
18+ import { getState , dispatch } from './state' ;
1919import {
2020 callAsyncFn ,
2121 getAllHooksForDescribe ,
@@ -29,22 +29,22 @@ import {
2929const Promise = getOriginalPromise ( ) ;
3030
3131const run = async ( ) : Promise < RunResult > => {
32- const { rootDescribeBlock } = getState ( ) ;
33- dispatch ( { name : 'run_start' } ) ;
32+ const { rootDescribeBlock} = getState ( ) ;
33+ dispatch ( { name : 'run_start' } ) ;
3434 await _runTestsForDescribeBlock ( rootDescribeBlock ) ;
35- dispatch ( { name : 'run_finish' } ) ;
35+ dispatch ( { name : 'run_finish' } ) ;
3636 return makeRunResult (
3737 getState ( ) . rootDescribeBlock ,
3838 getState ( ) . unhandledErrors ,
3939 ) ;
4040} ;
4141
4242const _runTestsForDescribeBlock = async ( describeBlock : DescribeBlock ) => {
43- dispatch ( { describeBlock, name : 'run_describe_start' } ) ;
44- const { beforeAll, afterAll } = getAllHooksForDescribe ( describeBlock ) ;
43+ dispatch ( { describeBlock, name : 'run_describe_start' } ) ;
44+ const { beforeAll, afterAll} = getAllHooksForDescribe ( describeBlock ) ;
4545
4646 for ( const hook of beforeAll ) {
47- await _callHook ( { describeBlock, hook } ) ;
47+ await _callHook ( { describeBlock, hook} ) ;
4848 }
4949
5050 // Tests that fail and are retried we run after other tests
@@ -78,47 +78,47 @@ const _runTestsForDescribeBlock = async (describeBlock: DescribeBlock) => {
7878 }
7979
8080 for ( const hook of afterAll ) {
81- await _callHook ( { describeBlock, hook } ) ;
81+ await _callHook ( { describeBlock, hook} ) ;
8282 }
83- dispatch ( { describeBlock, name : 'run_describe_finish' } ) ;
83+ dispatch ( { describeBlock, name : 'run_describe_finish' } ) ;
8484} ;
8585
8686const _runTest = async ( test : TestEntry ) : Promise < void > => {
87- dispatch ( { name : 'test_start' , test } ) ;
87+ dispatch ( { name : 'test_start' , test} ) ;
8888 const testContext = Object . create ( null ) ;
89- const { hasFocusedTests, testNamePattern } = getState ( ) ;
89+ const { hasFocusedTests, testNamePattern} = getState ( ) ;
9090
9191 const isSkipped =
9292 test . mode === 'skip' ||
9393 ( hasFocusedTests && test . mode !== 'only' ) ||
9494 ( testNamePattern && ! testNamePattern . test ( getTestID ( test ) ) ) ;
9595
9696 if ( isSkipped ) {
97- dispatch ( { name : 'test_skip' , test } ) ;
97+ dispatch ( { name : 'test_skip' , test} ) ;
9898 return ;
9999 }
100100
101- const { afterEach, beforeEach } = getEachHooksForTest ( test ) ;
101+ const { afterEach, beforeEach} = getEachHooksForTest ( test ) ;
102102
103103 for ( const hook of beforeEach ) {
104104 if ( test . errors . length ) {
105105 // If any of the before hooks failed already, we don't run any
106106 // hooks after that.
107107 break ;
108108 }
109- await _callHook ( { hook, test, testContext } ) ;
109+ await _callHook ( { hook, test, testContext} ) ;
110110 }
111111
112112 await _callTest ( test , testContext ) ;
113113
114114 for ( const hook of afterEach ) {
115- await _callHook ( { hook, test, testContext } ) ;
115+ await _callHook ( { hook, test, testContext} ) ;
116116 }
117117
118118 // `afterAll` hooks should not affect test status (pass or fail), because if
119119 // we had a global `afterAll` hook it would block all existing tests until
120120 // this hook is executed. So we dispatche `test_done` right away.
121- dispatch ( { name : 'test_done' , test } ) ;
121+ dispatch ( { name : 'test_done' , test} ) ;
122122} ;
123123
124124const _callHook = ( {
@@ -127,25 +127,25 @@ const _callHook = ({
127127 describeBlock,
128128 testContext,
129129} : {
130- hook : Hook ,
131- describeBlock ?: DescribeBlock ,
132- test ?: TestEntry ,
133- testContext ?: TestContext ,
134- } ) : Promise < mixed > => {
135- dispatch ( { hook, name : 'hook_start' } ) ;
130+ hook : Hook ,
131+ describeBlock ?: DescribeBlock ,
132+ test ?: TestEntry ,
133+ testContext ?: TestContext ,
134+ } ) : Promise < mixed > => {
135+ dispatch ( { hook, name : 'hook_start' } ) ;
136136 const timeout = hook . timeout || getState ( ) . testTimeout ;
137- return callAsyncFn ( hook . fn , testContext , { isHook : true , timeout } )
138- . then ( ( ) => dispatch ( { describeBlock, hook, name : 'hook_success' , test } ) )
137+ return callAsyncFn ( hook . fn , testContext , { isHook : true , timeout} )
138+ . then ( ( ) => dispatch ( { describeBlock, hook, name : 'hook_success' , test} ) )
139139 . catch ( error =>
140- dispatch ( { describeBlock, error, hook, name : 'hook_failure' , test } ) ,
141- ) ;
140+ dispatch ( { describeBlock, error, hook, name : 'hook_failure' , test} ) ,
141+ ) ;
142142} ;
143143
144144const _callTest = async (
145145 test : TestEntry ,
146146 testContext : TestContext ,
147147) : Promise < void > => {
148- dispatch ( { name : 'test_fn_start' , test } ) ;
148+ dispatch ( { name : 'test_fn_start' , test} ) ;
149149 const timeout = test . timeout || getState ( ) . testTimeout ;
150150 invariant ( test . fn , `Tests with no 'fn' should have 'mode' set to 'skipped'` ) ;
151151
@@ -154,9 +154,9 @@ const _callTest = async (
154154 return;
155155 }
156156
157- await callAsyncFn ( test . fn , testContext , { isHook : false , timeout } )
158- . then ( ( ) => dispatch ( { name : 'test_fn_success' , test } ) )
159- . catch ( error => dispatch ( { error, name : 'test_fn_failure' , test } ) ) ;
157+ await callAsyncFn ( test . fn , testContext , { isHook : false , timeout} )
158+ . then ( ( ) => dispatch ( { name : 'test_fn_success' , test} ) )
159+ . catch ( error => dispatch ( { error, name : 'test_fn_failure' , test} ) ) ;
160160} ;
161161
162162export default run ;
0 commit comments