Skip to content

Commit

Permalink
feat(ci): throw error in ci env for .only and missing snapshot (#4836)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearmini authored Mar 27, 2023
1 parent 43a4ce8 commit a49f216
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions __tests__/integration/utils/filterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export function filterTests(test) {
// @ts-ignore
([, { only = false }]) => only,
);
if (onlys.length !== 0 && process.env.CI === 'true') {
throw new Error('Please remove `test.only`.');
}
const runnables = onlys.length === 0 ? tests : onlys;
return runnables.filter(
// @ts-ignore
Expand Down
3 changes: 3 additions & 0 deletions __tests__/integration/utils/toMatchCanvasSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export async function toMatchCanvasSnapshot(
try {
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
if (!fs.existsSync(expectedPath)) {
if (process.env.CI === 'true') {
throw new Error(`Please generate golden image for ${namePath}`);
}
console.warn(`! generate ${namePath}`);
await writePNG(canvas, expectedPath);
return {
Expand Down
3 changes: 3 additions & 0 deletions __tests__/integration/utils/toMatchDOMSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export async function toMatchDOMSnapshot(
: 'null';

if (!fs.existsSync(expectedPath)) {
if (process.env.CI === 'true') {
throw new Error(`Please generate golden image for ${namePath}`);
}
console.warn(`! generate ${namePath}`);
await fs.writeFileSync(expectedPath, actual);
return {
Expand Down

0 comments on commit a49f216

Please sign in to comment.