-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(test): use a fixture rather than afterEach for coverage (#259)
- Loading branch information
Showing
14 changed files
with
30 additions
and
50 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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import reportCoverage from '@agnos-ui/code-coverage/reportCoverage'; | ||
import type {Page, TestInfo} from '@playwright/test'; | ||
import {test as base} from '@playwright/test'; | ||
|
||
async function afterEach({page}: {page: Page}, testInfo: TestInfo) { | ||
const coverage: string = await page.evaluate(() => { | ||
return JSON.stringify((window as any).__coverage__); | ||
}); | ||
if (coverage && testInfo.project.name.endsWith(':chromium')) { | ||
reportCoverage(__dirname, coverage); | ||
} | ||
} | ||
export {expect} from '@playwright/test'; | ||
|
||
export type FixtureOptions = { | ||
framework?: string; | ||
coverage: void; | ||
}; | ||
|
||
export function getTest() { | ||
const test = base.extend<FixtureOptions>({ | ||
framework: [undefined, {option: true}], | ||
}); | ||
test.afterEach(afterEach); | ||
return test; | ||
} | ||
export const test = base.extend<FixtureOptions>({ | ||
framework: [undefined, {option: true}], | ||
coverage: [ | ||
async ({page, browserName}, use) => { | ||
await use(); | ||
const coverage: string = await page.evaluate(() => { | ||
return JSON.stringify((window as any).__coverage__); | ||
}); | ||
if (coverage && browserName === 'chromium') { | ||
reportCoverage(__dirname, coverage); | ||
} | ||
}, | ||
{auto: true}, | ||
], | ||
}); |
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
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
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