-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathjest_spec.lua
More file actions
68 lines (56 loc) · 1.46 KB
/
jest_spec.lua
File metadata and controls
68 lines (56 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local async = require("plenary.async.tests")
local wrap = require("plenary.async.async").wrap
local dap = require("dap")
local test_utils = require("__dap_js_test_util")
local workDir = test_utils.test_file("jest")
local launch_config = {
type = "pwa-node",
request = "launch",
name = "Debug Jest Tests",
-- trace = true,
runtimeExecutable = "node",
runtimeArgs = {
"./node_modules/jest/bin/jest.js",
"--runInBand",
},
rootPath = workDir,
cwd = workDir,
console = "integratedTerminal",
internalConsoleOptions = "neverOpen",
}
describe("pwa-node jest", function()
before_each(function()
test_utils.reset()
test_utils.setup_dapjs()
end)
describe("typescript", function()
async.it(
"receives stdout from terminal",
wrap(function(done)
local terminated = false
local lines_found = {
["Tests: 1 failed, 1 passed, 2 total"] = false,
["Ran all test suites."] = false,
["Waiting for the debugger to disconnect..."] = false,
}
local function try_exit()
if terminated and vim.tbl_count(lines_found) == 0 then
done()
end
end
test_utils.get_terminal_remote(function(lines)
for _, line in ipairs(lines) do
lines_found[line] = nil
end
try_exit()
end)
test_utils.open_test("jest/integration.test.ts")
test_utils.add_listener("before", "event_terminated", function ()
terminated = true
try_exit()
end)
dap.run(launch_config)
end, 1)
)
end)
end)