@@ -188,6 +188,33 @@ describe("test case code emitter", () => {
188188 }
189189 } ) ;
190190 } ) ;
191+ it ( "should send the snapshot to the command" , ( ) => {
192+ const test = {
193+ id : "1" ,
194+ name : "example test case" ,
195+ commands : [
196+ {
197+ id : "2" ,
198+ command : "anUnknownCommand" ,
199+ target : "" ,
200+ value : ""
201+ }
202+ ]
203+ } ;
204+ const snapshot = {
205+ commands : {
206+ "2" : "command code"
207+ } ,
208+ setupHooks : [ ] ,
209+ teardownHooks : [ ]
210+ } ;
211+ expect ( TestCaseEmitter . emit ( test , undefined , snapshot ) ) . resolves . toEqual ( {
212+ id : "1" ,
213+ name : "example test case" ,
214+ test : "it(\"example test case\", async () => {await tests.example_test_case(driver, vars);await driver.getTitle().then(title => {expect(title).toBeDefined();});});" ,
215+ function : "tests.example_test_case = async function example_test_case(driver, vars, opts) {command code}"
216+ } ) ;
217+ } ) ;
191218 it ( "should emit a snapshot for a test case with setup and teardown hooks when skipStdLibEmitting is set" , ( ) => {
192219 const test = {
193220 id : "1" ,
@@ -207,4 +234,22 @@ describe("test case code emitter", () => {
207234 }
208235 } ) ;
209236 } ) ;
237+ it ( "should append the snapshot of the setup and teardown hooks to the test case" , ( ) => {
238+ const test = {
239+ id : "1" ,
240+ name : "example test case" ,
241+ commands : [ ]
242+ } ;
243+ const snapshot = {
244+ commands : { } ,
245+ setupHooks : [ "more setup" ] ,
246+ teardownHooks : [ "more teardown" ]
247+ } ;
248+ expect ( TestCaseEmitter . emit ( test , undefined , snapshot ) ) . resolves . toEqual ( {
249+ id : "1" ,
250+ name : "example test case" ,
251+ test : "it(\"example test case\", async () => {setup codemore setupawait tests.example_test_case(driver, vars);await driver.getTitle().then(title => {expect(title).toBeDefined();});teardown codemore teardown});" ,
252+ function : "tests.example_test_case = async function example_test_case(driver, vars, opts) {}"
253+ } ) ;
254+ } ) ;
210255} ) ;
0 commit comments