-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(trace-viewer): spawn trace viewer tests
- Loading branch information
1 parent
643d3c3
commit 23a6af8
Showing
5 changed files
with
175 additions
and
3 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
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
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
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,135 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { enableConfigs, expect, selectConfig, selectTestItem, test, traceViewerInfo } from './utils'; | ||
|
||
test.beforeEach(({ showBrowser }) => { | ||
test.skip(showBrowser); | ||
// prevents spawn trace viewer process from opening in browser | ||
process.env.PWTEST_UNDER_TEST = '1'; | ||
}); | ||
|
||
test.use({ showTrace: true, envRemoteName: 'ssh-remote' }); | ||
|
||
test('@smoke should open trace viewer', async ({ activate }) => { | ||
const { vscode, testController } = await activate({ | ||
'playwright.config.js': `module.exports = { testDir: 'tests' }`, | ||
'tests/test.spec.ts': ` | ||
import { test } from '@playwright/test'; | ||
test('should pass', async () => {}); | ||
`, | ||
}); | ||
|
||
await testController.run(); | ||
await testController.expandTestItems(/test.spec/); | ||
selectTestItem(testController.findTestItems(/pass/)[0]); | ||
|
||
await expect.poll(() => traceViewerInfo(vscode)).toMatchObject({ | ||
type: 'spawn', | ||
traceFile: expect.stringContaining('pass'), | ||
}); | ||
}); | ||
|
||
test('should change opened file in trace viewer', async ({ activate }) => { | ||
const { vscode, testController } = await activate({ | ||
'playwright.config.js': `module.exports = { testDir: 'tests' }`, | ||
'tests/test.spec.ts': ` | ||
import { test } from '@playwright/test'; | ||
test('one', async () => {}); | ||
test('two', async () => {}); | ||
`, | ||
}); | ||
|
||
await testController.run(); | ||
await testController.expandTestItems(/test.spec/); | ||
|
||
selectTestItem(testController.findTestItems(/one/)[0]); | ||
|
||
await expect.poll(() => traceViewerInfo(vscode)).toMatchObject({ | ||
type: 'spawn', | ||
traceFile: expect.stringContaining('one'), | ||
}); | ||
|
||
selectTestItem(testController.findTestItems(/two/)[0]); | ||
|
||
await expect.poll(() => traceViewerInfo(vscode)).toMatchObject({ | ||
type: 'spawn', | ||
traceFile: expect.stringContaining('two'), | ||
}); | ||
}); | ||
|
||
test('should not open trace viewer if test did not run', async ({ activate }) => { | ||
const { vscode, testController } = await activate({ | ||
'playwright.config.js': `module.exports = { testDir: 'tests' }`, | ||
'tests/test.spec.ts': ` | ||
import { test } from '@playwright/test'; | ||
test('should pass', async () => {}); | ||
`, | ||
}); | ||
|
||
await testController.expandTestItems(/test.spec/); | ||
selectTestItem(testController.findTestItems(/pass/)[0]); | ||
|
||
await expect.poll(() => traceViewerInfo(vscode)).toBeUndefined(); | ||
}); | ||
|
||
test('should open new trace viewer when another test config is selected', async ({ activate }) => { | ||
const { vscode, testController } = await activate({ | ||
'playwright1.config.js': `module.exports = { testDir: 'tests1' }`, | ||
'playwright2.config.js': `module.exports = { testDir: 'tests2' }`, | ||
'tests1/test.spec.ts': ` | ||
import { test } from '@playwright/test'; | ||
test('one', () => {}); | ||
`, | ||
'tests2/test.spec.ts': ` | ||
import { test } from '@playwright/test'; | ||
test('one', () => {}); | ||
`, | ||
}); | ||
|
||
await enableConfigs(vscode, ['playwright1.config.js', 'playwright2.config.js']); | ||
await selectConfig(vscode, 'playwright1.config.js'); | ||
|
||
await testController.expandTestItems(/test.spec/); | ||
const testItems = testController.findTestItems(/one/); | ||
await testController.run(testItems); | ||
|
||
selectTestItem(testItems[0]); | ||
|
||
await expect.poll(() => traceViewerInfo(vscode)).toMatchObject({ | ||
type: 'spawn', | ||
serverUrlPrefix: expect.stringContaining('http'), | ||
testConfigFile: expect.stringContaining('playwright1.config.js'), | ||
}); | ||
const serverUrlPrefix1 = traceViewerInfo(vscode); | ||
|
||
// closes opened trace viewer | ||
await selectConfig(vscode, 'playwright2.config.js'); | ||
|
||
await expect.poll(() => traceViewerInfo(vscode)).toBeUndefined(); | ||
|
||
// opens trace viewer from selected test config | ||
selectTestItem(testItems[0]); | ||
|
||
await expect.poll(() => traceViewerInfo(vscode)).toMatchObject({ | ||
type: 'spawn', | ||
serverUrlPrefix: expect.stringContaining('http'), | ||
testConfigFile: expect.stringContaining('playwright2.config.js'), | ||
}); | ||
const serverUrlPrefix2 = traceViewerInfo(vscode); | ||
|
||
expect(serverUrlPrefix2).not.toBe(serverUrlPrefix1); | ||
}); |
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