mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(html-reporter): open tests from required file (#11784)
This commit is contained in:
parent
c2f6462a6b
commit
3a5e8184b5
@ -151,7 +151,13 @@ class RawReporter {
|
||||
testMatch: serializePatterns(project.testMatch),
|
||||
timeout: project.timeout,
|
||||
},
|
||||
suites: suite.suites.map(s => this._serializeSuite(s))
|
||||
suites: suite.suites.map(fileSuite => {
|
||||
// fileId is based on the location of the enclosing file suite.
|
||||
// Don't use the file in test/suite location, it can be different
|
||||
// due to the source map / require.
|
||||
const fileId = calculateSha1(fileSuite.location!.file.split(path.sep).join('/'));
|
||||
return this._serializeSuite(fileSuite, fileId);
|
||||
})
|
||||
};
|
||||
for (const file of this.stepsInFile.keys()) {
|
||||
let source: string;
|
||||
@ -181,14 +187,13 @@ class RawReporter {
|
||||
return report;
|
||||
}
|
||||
|
||||
private _serializeSuite(suite: Suite): JsonSuite {
|
||||
private _serializeSuite(suite: Suite, fileId: string): JsonSuite {
|
||||
const location = this._relativeLocation(suite.location);
|
||||
const fileId = calculateSha1(location!.file.split(path.sep).join('/'));
|
||||
return {
|
||||
title: suite.title,
|
||||
fileId,
|
||||
location,
|
||||
suites: suite.suites.map(s => this._serializeSuite(s)),
|
||||
suites: suite.suites.map(s => this._serializeSuite(s, fileId)),
|
||||
tests: suite.tests.map(t => this._serializeTest(t, fileId)),
|
||||
hooks: [],
|
||||
};
|
||||
|
@ -461,3 +461,21 @@ test('should group similar / loop steps', async ({ runInlineTest, showReport, pa
|
||||
/expect\.toEqual.*20/,
|
||||
]);
|
||||
});
|
||||
|
||||
test('open tests from required file', async ({ runInlineTest, showReport, page }) => {
|
||||
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/11742' });
|
||||
const result = await runInlineTest({
|
||||
'inner.js': `
|
||||
const { test, expect } = pwt;
|
||||
test('sample', async ({}) => { expect(2).toBe(2); });
|
||||
`,
|
||||
'a.spec.js': `require('./inner')`
|
||||
}, { 'reporter': 'dot,html' });
|
||||
expect(result.exitCode).toBe(0);
|
||||
await showReport();
|
||||
|
||||
await page.locator('text=sample').first().click();
|
||||
await expect(page.locator('.tree-item-title')).toContainText([
|
||||
/expect\.toBe/,
|
||||
]);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user