-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add coverage for playwright tests
- Loading branch information
1 parent
fcf8d1b
commit 01d2f32
Showing
97 changed files
with
837 additions
and
234 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,59 @@ | ||
import { test as ctBase, expect } from "@playwright/experimental-ct-react17"; | ||
import mcr from "monocart-coverage-reports"; | ||
|
||
const coverageOptions = { | ||
reports: [ | ||
[ | ||
"json", | ||
{ | ||
file: "coverage.json", | ||
}, | ||
], | ||
], | ||
lcov: true, | ||
name: "My Istanbul Report", | ||
all: { | ||
dir: ["./src"], | ||
filter: { | ||
"**/*.component.tsx": true, | ||
"**/*.style.ts": true, | ||
}, | ||
}, | ||
outputDir: "./playwright/coverage", | ||
}; | ||
|
||
const test = ctBase.extend({ | ||
autoTestFixture: [ | ||
async ({ page }, use) => { | ||
// coverage API is chromium only | ||
if (test.info().project.name === "chromium") { | ||
await Promise.all([ | ||
page.coverage.startJSCoverage({ | ||
resetOnNavigation: false, | ||
}), | ||
page.coverage.startCSSCoverage({ | ||
resetOnNavigation: false, | ||
}), | ||
]); | ||
} | ||
|
||
await use("autoTestFixture"); | ||
|
||
if (test.info().project.name === "chromium") { | ||
const [jsCoverage, cssCoverage] = await Promise.all([ | ||
page.coverage.stopJSCoverage(), | ||
page.coverage.stopCSSCoverage(), | ||
]); | ||
const coverageList = [...jsCoverage, ...cssCoverage]; | ||
await mcr(coverageOptions).add(coverageList); | ||
await mcr(coverageOptions).generate(); | ||
} | ||
}, | ||
{ | ||
scope: "test", | ||
auto: true, | ||
}, | ||
], | ||
}); | ||
|
||
export { test, expect }; |
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,41 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const destinationDir = "./merged-coverage"; | ||
|
||
function copyJSONFile(dir) { | ||
// Ensure the destination directory exists | ||
if (!fs.existsSync(destinationDir)) { | ||
fs.mkdirSync(destinationDir, { recursive: true }); | ||
} | ||
// Read files in the source directory | ||
fs.readdir(dir, (error, files) => { | ||
if (error) { | ||
console.error("Error reading source directory:", error); | ||
return; | ||
} | ||
|
||
const jsonFiles = files.filter( | ||
(file) => path.extname(file).toLowerCase() === ".json", | ||
); | ||
|
||
// Copy JSON files to destination directory | ||
jsonFiles.forEach((file) => { | ||
fs.copyFile( | ||
path.join(dir, file), | ||
path.join(destinationDir, file), | ||
fs.constants.COPYFILE_FICLONE, // Optional flags (use fs.constants.COPYFILE_EXCL to prevent overwriting) | ||
(err) => { | ||
if (err) { | ||
console.error(`Error copying file ${file}:`, err); | ||
} else { | ||
console.log(`Copied file ${file} to ${destinationDir}`); | ||
} | ||
}, | ||
); | ||
}); | ||
}); | ||
} | ||
|
||
copyJSONFile("./playwright/coverage"); | ||
copyJSONFile("./coverage"); |
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
2 changes: 1 addition & 1 deletion
2
src/components/advanced-color-picker/advanced-color-picker.pw.tsx
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
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
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
Oops, something went wrong.