Skip to content

Commit 18bcb92

Browse files
committed
Add custom timeout for tests
1 parent 1dd2d15 commit 18bcb92

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/metrics.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@
8585
for (const name in metadata.plugins) {
8686
const cases = yaml
8787
.load(fs.readFileSync(path.join(__dirname, "../source/plugins", name, "tests.yml"), "utf8"))
88-
.map(({name:test, with:inputs, modes = []}) => {
88+
.map(({name:test, with:inputs, modes = [], timeout}) => {
8989
const skip = new Set(Object.entries(metadata.templates).filter(([_, {readme:{compatibility}}]) => !compatibility[name]).map(([template]) => template))
9090
if (!(metadata.plugins[name].supports.includes("repository")))
9191
skip.add("repository")
92-
return [test, inputs, {skip:[...skip], modes}]
92+
return [test, inputs, {skip:[...skip], modes, timeout}]
9393
})
9494
tests.push(...cases)
9595
}
@@ -101,11 +101,11 @@
101101
["terminal", {}],
102102
["repository", {repo:"metrics"}],
103103
])("Template : %s", (template, query) => {
104-
for (const [name, input, {skip = [], modes = []} = {}] of tests)
104+
for (const [name, input, {skip = [], modes = []} = {}, timeout] of tests)
105105
if ((skip.includes(template))||((modes.length)&&(!modes.includes("action"))))
106106
test.skip(name, () => null)
107107
else
108-
test(name, async () => expect(await action.run({template, base:"", query:JSON.stringify(query), plugins_errors_fatal:true, dryrun:true, use_mocked_data:true, verify:true, ...input})).toBe(true))
108+
test(name, async () => expect(await action.run({template, base:"", query:JSON.stringify(query), plugins_errors_fatal:true, dryrun:true, use_mocked_data:true, verify:true, ...input})).toBe(true), timeout)
109109
})
110110
)
111111

@@ -115,11 +115,11 @@
115115
["terminal", {}],
116116
["repository", {repo:"metrics"}],
117117
])("Template : %s", (template, query) => {
118-
for (const [name, input, {skip = [], modes = []} = {}] of tests)
118+
for (const [name, input, {skip = [], modes = []} = {}, timeout] of tests)
119119
if ((skip.includes(template))||((modes.length)&&(!modes.includes("web"))))
120120
test.skip(name, () => null)
121121
else
122-
test(name, async () => expect(await web.run({template, base:0, ...query, plugins_errors_fatal:true, verify:true, ...input})).toBe(true))
122+
test(name, async () => expect(await web.run({template, base:0, ...query, plugins_errors_fatal:true, verify:true, ...input})).toBe(true), timeout)
123123
})
124124
)
125125

@@ -128,10 +128,10 @@
128128
["classic", {}],
129129
["terminal", {}],
130130
])("Template : %s", (template, query) => {
131-
for (const [name, input, {skip = [], modes = []} = {}] of tests)
131+
for (const [name, input, {skip = [], modes = []} = {}, timeout] of tests)
132132
if ((skip.includes(template))||((modes.length)&&(!modes.includes("placeholder"))))
133133
test.skip(name, () => null)
134134
else
135-
test(name, async () => expect(await placeholder.run({template, base:0, ...query, ...input})).toBe(true))
135+
test(name, async () => expect(await placeholder.run({template, base:0, ...query, ...input})).toBe(true), timeout)
136136
})
137137
)

0 commit comments

Comments
 (0)