Skip to content

Commit 262fbee

Browse files
committed
Refactor timeout to before hook
1 parent b849fa9 commit 262fbee

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

extensions/ql-vscode/src/vscode-tests/no-workspace/query-results.test.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,16 @@ describe('query-results', () => {
169169
const interpretedResultsPath = path.join(tmpDir.name, 'interpreted.json');
170170
const sourceInfo = {};
171171

172-
beforeEach(() => {
172+
beforeEach(function(done) {
173173
spy = sandbox.mock();
174174
spy.returns({ a: '1234' });
175175

176176
mockServer = {
177177
interpretBqrsSarif: spy
178178
} as unknown as CodeQLCliServer;
179+
180+
// Time out all following tests in 2 minutes.
181+
setTimeout(done, 2 * 60 * 1000);
179182
});
180183

181184
afterEach(async () => {
@@ -184,9 +187,6 @@ describe('query-results', () => {
184187
});
185188

186189
it('should interpretResultsSarif', async function() {
187-
// up to 2 minutes per test
188-
this.timeout(2 * 60 * 1000);
189-
190190
const results = await interpretResultsSarif(
191191
mockServer,
192192
metadata,
@@ -204,9 +204,6 @@ describe('query-results', () => {
204204
});
205205

206206
it('should interpretBqrsSarif without ID', async function() {
207-
// up to 2 minutes per test
208-
this.timeout(2 * 60 * 1000);
209-
210207
delete metadata.id;
211208
const results = await interpretResultsSarif(
212209
mockServer,
@@ -224,9 +221,6 @@ describe('query-results', () => {
224221
});
225222

226223
it('should use sarifParser on a valid small SARIF file', async function() {
227-
// up to 2 minutes per test
228-
this.timeout(2 * 60 * 1000);
229-
230224
fs.writeFileSync(interpretedResultsPath, JSON.stringify({
231225
runs: [{ results: [] }] // A run needs results to succeed.
232226
}), 'utf8');
@@ -246,9 +240,6 @@ describe('query-results', () => {
246240
});
247241

248242
it('should throw an error on an invalid small SARIF file', async function() {
249-
// up to 2 minutes per test
250-
this.timeout(2 * 60 * 1000);
251-
252243
fs.writeFileSync(interpretedResultsPath, JSON.stringify({
253244
a: '6' // Invalid: no runs or results
254245
}), 'utf8');
@@ -268,9 +259,6 @@ describe('query-results', () => {
268259
});
269260

270261
it('should use sarifParser on a valid large SARIF file', async function() {
271-
// up to 2 minutes per test
272-
this.timeout(2 * 60 * 1000);
273-
274262
const validSarifStream = fs.createWriteStream(interpretedResultsPath, { flags: 'w' });
275263

276264
const finished = new Promise((res, rej) => {
@@ -318,9 +306,6 @@ describe('query-results', () => {
318306
});
319307

320308
it('should throw an error on an invalid large SARIF file', async function() {
321-
// up to 2 minutes per test
322-
this.timeout(2 * 60 * 1000);
323-
324309
const invalidLargeInterpretedResultsPath = path.join(tmpDir.name, 'interpreted.json');
325310
const invalidSarifStream = fs.createWriteStream(invalidLargeInterpretedResultsPath, { flags: 'w' });
326311

0 commit comments

Comments
 (0)