-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add actual test execution of hooks tests
- Loading branch information
1 parent
baf3519
commit 79065e4
Showing
1 changed file
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/** | ||
* Copyright (C) Daniel Kuschny (Danielku15) and contributors. | ||
* Copyright (C) Microsoft Corporation. All rights reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
import { expect } from 'chai'; | ||
import * as vscode from 'vscode'; | ||
import { captureTestRun, expectTestTree, getController } from '../util'; | ||
|
||
describe('with-hooks', () => { | ||
it('discovers tests', async () => { | ||
const c = await getController(); | ||
|
||
expectTestTree(c, [ | ||
[ | ||
'hello.test.js', | ||
[ | ||
['with beforeAll hook', [['addition'], ['failing'], ['subtraction']]], | ||
['with beforeEach hook', [['addition'], ['failing'], ['subtraction']]], | ||
[ | ||
'with broken after hook (suite must be failed)', | ||
[['addition'], ['failing'], ['subtraction']], | ||
], | ||
[ | ||
'with broken afterEach hook (suite must be failed)', | ||
[['addition (success)'], ['failing (skipped)'], ['subtraction (skipped)']], | ||
], | ||
[ | ||
'with broken before hook (suite must be failed)', | ||
[['addition (skipped)'], ['failing (skipped)'], ['subtraction (skipped)']], | ||
], | ||
[ | ||
'with broken beforeEach hook (suite must be failed)', | ||
[['addition (skipped)'], ['failing (skipped)'], ['subtraction (skipped)']], | ||
], | ||
], | ||
], | ||
]); | ||
}); | ||
|
||
it('runs tests', async () => { | ||
const c = await getController(); | ||
const profiles = c.profiles; | ||
expect(profiles).to.have.lengthOf(2); | ||
|
||
const run = await captureTestRun( | ||
c, | ||
new vscode.TestRunRequest( | ||
undefined, | ||
undefined, | ||
profiles.find((p) => p.kind === vscode.TestRunProfileKind.Run), | ||
), | ||
); | ||
|
||
run.expectStates({ | ||
'hello.test.js/with beforeAll hook/addition': ['enqueued', 'started', 'passed'], | ||
'hello.test.js/with beforeAll hook/subtraction': ['enqueued', 'started', 'passed'], | ||
'hello.test.js/with beforeAll hook/failing': ['enqueued', 'started', 'failed'], | ||
'hello.test.js/with beforeEach hook/addition': ['enqueued', 'started', 'passed'], | ||
'hello.test.js/with beforeEach hook/subtraction': ['enqueued', 'started', 'passed'], | ||
'hello.test.js/with beforeEach hook/failing': ['enqueued', 'started', 'failed'], | ||
'hello.test.js/with broken before hook (suite must be failed)/addition (skipped)': [ | ||
'enqueued', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken before hook (suite must be failed)/subtraction (skipped)': [ | ||
'enqueued', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken before hook (suite must be failed)/failing (skipped)': [ | ||
'enqueued', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken beforeEach hook (suite must be failed)/addition (skipped)': [ | ||
'enqueued', | ||
'started', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken beforeEach hook (suite must be failed)/subtraction (skipped)': [ | ||
'enqueued', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken beforeEach hook (suite must be failed)/failing (skipped)': [ | ||
'enqueued', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken after hook (suite must be failed)/addition': [ | ||
'enqueued', | ||
'started', | ||
'passed', | ||
], | ||
'hello.test.js/with broken after hook (suite must be failed)/subtraction': [ | ||
'enqueued', | ||
'started', | ||
'passed', | ||
], | ||
'hello.test.js/with broken after hook (suite must be failed)/failing': [ | ||
'enqueued', | ||
'started', | ||
'failed', | ||
], | ||
'hello.test.js/with broken afterEach hook (suite must be failed)/addition (success)': [ | ||
'enqueued', | ||
'started', | ||
'passed', | ||
], | ||
'hello.test.js/with broken afterEach hook (suite must be failed)/subtraction (skipped)': [ | ||
'enqueued', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken afterEach hook (suite must be failed)/failing (skipped)': [ | ||
'enqueued', | ||
'skipped', | ||
], | ||
'hello.test.js/with broken before hook (suite must be failed)': ['failed'], | ||
'hello.test.js/with broken beforeEach hook (suite must be failed)': ['failed'], | ||
'hello.test.js/with broken after hook (suite must be failed)': ['failed'], | ||
'hello.test.js/with broken afterEach hook (suite must be failed)': ['failed'], | ||
}); | ||
}); | ||
}); |