@@ -2,6 +2,7 @@ local breakpoints = require("dap.breakpoints")
22local async = require (" plenary.async.tests" )
33local wrap = require (" plenary.async.async" ).wrap
44local dapjs = require (" dap-vscode-js" )
5+ local js_session = require " dap-vscode-js.session"
56local dap = require (" dap" )
67local test_utils = require (" __dap_js_test_util" )
78local config = require (" dap-vscode-js.config" )
@@ -12,7 +13,7 @@ local launch_config = {
1213 type = " pwa-node" ,
1314 request = " launch" ,
1415 name = " Debug Jest Tests" ,
15- trace = true ,
16+ -- trace = true,
1617 runtimeExecutable = " node" ,
1718 runtimeArgs = {
1819 " ./node_modules/jest/bin/jest.js" ,
@@ -34,38 +35,35 @@ describe("pwa-node jest", function()
3435 async .it (
3536 " receives stdout from terminal" ,
3637 wrap (function (done )
37- local term_lines = {}
38+ local terminated = false
3839
39- local terminated = false
40- local cleanup
40+ local lines_found = {
41+ [" Tests: 1 failed, 1 passed, 2 total" ] = false ,
42+ [" Ran all test suites." ] = false ,
43+ [" Waiting for the debugger to disconnect..." ] = false ,
44+ }
4145
4246 local function try_exit ()
43- if terminated and # term_lines == 98 then
44- assert .equal (term_lines [92 ], " Tests: 1 failed, 1 passed, 2 total" )
45-
46- cleanup ()
47- done ()
48- end
47+ if terminated and vim .tbl_count (lines_found ) == 0 then
48+ done ()
49+ end
4950 end
5051
51- cleanup = test_utils .get_terminal_remote (function (lines )
52+ test_utils .get_terminal_remote (function (lines )
5253 for _ , line in ipairs (lines ) do
53- table.insert ( term_lines , line )
54+ lines_found [ line ] = nil
5455 end
5556
5657 try_exit ()
5758 end )
5859
5960 test_utils .open_test (" jest/integration.test.ts" )
6061
61- test_utils .add_listener (" before" , " event_output" , function (session , body )
62- print (body .output )
63- end )
62+ test_utils .on_session_end (function ()
63+ terminated = true
6464
65- test_utils .add_listener (" before" , " event_terminated" , function ()
66- terminated = true
67- try_exit ()
68- end )
65+ try_exit ()
66+ end )
6967
7068 dap .run (launch_config )
7169 end , 1 )
0 commit comments