@@ -25,14 +25,7 @@ describe('test case code emitter', () => {
2525 name : 'example test case' ,
2626 commands : [ ] ,
2727 }
28- return expect ( TestCaseEmitter . emit ( test ) ) . resolves . toEqual ( {
29- id : '1' ,
30- name : 'example test case' ,
31- test : `it("${
32- test . name
33- } ", async () => {await tests["example test case"](driver, vars);expect(true).toBeTruthy();});`,
34- function : 'tests["example test case"] = async (driver, vars, opts) => {}' ,
35- } )
28+ return expect ( TestCaseEmitter . emit ( test ) ) . resolves . toMatchSnapshot ( )
3629 } )
3730 it ( 'should emit a test with a single command' , ( ) => {
3831 const test = {
@@ -46,16 +39,7 @@ describe('test case code emitter', () => {
4639 } ,
4740 ] ,
4841 }
49- return expect ( TestCaseEmitter . emit ( test ) ) . resolves . toEqual ( {
50- id : '1' ,
51- name : 'example test case' ,
52- test : `it("${
53- test . name
54- } ", async () => {await tests["example test case"](driver, vars);expect(true).toBeTruthy();});`,
55- function : `tests["example test case"] = async (driver, vars, opts) => {await driver.get((new URL("${
56- test . commands [ 0 ] . target
57- } ", BASE_URL)).href);}`,
58- } )
42+ return expect ( TestCaseEmitter . emit ( test ) ) . resolves . toMatchSnapshot ( )
5943 } )
6044 it ( 'should emit a test with multiple commands' , ( ) => {
6145 const test = {
@@ -79,20 +63,7 @@ describe('test case code emitter', () => {
7963 } ,
8064 ] ,
8165 }
82- return expect ( TestCaseEmitter . emit ( test ) ) . resolves . toEqual ( {
83- id : '1' ,
84- name : 'example test case' ,
85- test : `it("${
86- test . name
87- } ", async () => {await tests["example test case"](driver, vars);expect(true).toBeTruthy();});`,
88- function : `tests["example test case"] = async (driver, vars, opts) => {await driver.get((new URL("${
89- test . commands [ 0 ] . target
90- } ", BASE_URL)).href);await driver.get((new URL("${
91- test . commands [ 1 ] . target
92- } ", BASE_URL)).href);await driver.get((new URL("${
93- test . commands [ 2 ] . target
94- } ", BASE_URL)).href);}`,
95- } )
66+ return expect ( TestCaseEmitter . emit ( test ) ) . resolves . toMatchSnapshot ( )
9667 } )
9768 it ( 'should reject a test with failed commands' , ( ) => {
9869 const test = {
@@ -158,7 +129,7 @@ describe('test case code emitter', () => {
158129 test :
159130 'it("silence", async () => {await tests["silence"](driver, vars);expect(true).toBeTruthy();});' ,
160131 function :
161- 'tests["silence"] = async (driver, vars, opts) => {throw new Error("Unknown command doesntExist");}' ,
132+ 'tests["silence"] = async (driver, vars, opts = {} ) => {throw new Error("Unknown command doesntExist");}' ,
162133 } )
163134 } )
164135 it ( 'should emit an empty snapshot for an empty test case when skipStdLibEmitting is set' , ( ) => {
@@ -167,7 +138,7 @@ describe('test case code emitter', () => {
167138 name : 'example test case' ,
168139 commands : [ ] ,
169140 }
170- expect (
141+ return expect (
171142 TestCaseEmitter . emit ( test , { skipStdLibEmitting : true } )
172143 ) . resolves . toEqual ( { } )
173144 } )
@@ -183,7 +154,7 @@ describe('test case code emitter', () => {
183154 } ,
184155 ] ,
185156 }
186- expect (
157+ return expect (
187158 TestCaseEmitter . emit ( test , { skipStdLibEmitting : true } )
188159 ) . resolves . toEqual ( { } )
189160 } )
@@ -201,7 +172,7 @@ describe('test case code emitter', () => {
201172 ] ,
202173 }
203174 CommandEmitter . registerEmitter ( 'aNewCommand' , ( ) => 'command code' )
204- expect (
175+ return expect (
205176 TestCaseEmitter . emit ( test , { skipStdLibEmitting : true } )
206177 ) . resolves . toEqual ( {
207178 id : '1' ,
@@ -234,14 +205,9 @@ describe('test case code emitter', () => {
234205 setupHooks : [ ] ,
235206 teardownHooks : [ ] ,
236207 }
237- expect ( TestCaseEmitter . emit ( test , undefined , snapshot ) ) . resolves . toEqual ( {
238- id : '1' ,
239- name : 'example test case' ,
240- test :
241- 'it("example test case", async () => {await tests["example test case"](driver, vars);expect(true).toBeTruthy();});' ,
242- function :
243- 'tests["example test case"] = async (driver, vars, opts) => {command code}' ,
244- } )
208+ return expect (
209+ TestCaseEmitter . emit ( test , undefined , snapshot )
210+ ) . resolves . toMatchSnapshot ( )
245211 } )
246212 it ( 'should emit a snapshot for a test case with setup and teardown hooks when skipStdLibEmitting is set' , ( ) => {
247213 const test = {
@@ -253,7 +219,7 @@ describe('test case code emitter', () => {
253219 setup : 'setup code' ,
254220 teardown : 'teardown code' ,
255221 } ) )
256- expect (
222+ return expect (
257223 TestCaseEmitter . emit ( test , { skipStdLibEmitting : true } )
258224 ) . resolves . toEqual ( {
259225 id : '1' ,
@@ -274,7 +240,7 @@ describe('test case code emitter', () => {
274240 setup : '' ,
275241 teardown : '' ,
276242 } ) )
277- expect (
243+ return expect (
278244 TestCaseEmitter . emit ( test , { skipStdLibEmitting : true } )
279245 ) . resolves . toEqual ( {
280246 id : '1' ,
@@ -296,12 +262,8 @@ describe('test case code emitter', () => {
296262 setupHooks : [ 'more setup' ] ,
297263 teardownHooks : [ 'more teardown' ] ,
298264 }
299- expect ( TestCaseEmitter . emit ( test , undefined , snapshot ) ) . resolves . toEqual ( {
300- id : '1' ,
301- name : 'example test case' ,
302- test :
303- 'it("example test case", async () => {setup codemore setupawait tests["example test case"](driver, vars);expect(true).toBeTruthy();teardown codemore teardown});' ,
304- function : 'tests["example test case"] = async (driver, vars, opts) => {}' ,
305- } )
265+ return expect (
266+ TestCaseEmitter . emit ( test , undefined , snapshot )
267+ ) . resolves . toMatchSnapshot ( )
306268 } )
307269} )
0 commit comments