Skip to content

Commit

Permalink
another set timeout try
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbenz committed Jan 12, 2022
1 parent 601db6f commit a2b6cb8
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions packages/page-experience/tests/Checks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let CREATE_SNAPSHOT = process.env.PAGE_EXPERIENCE_SNAPSHOT;

const pageExperienceGuide = new PageExperienceGuide();
let checks;
jest.setTimeout(60000);

beforeAll(async () => {
await pageExperienceGuide.setup();
Expand All @@ -35,32 +36,28 @@ describe('Checks', () => {
const testCaseDir = path.join(TEST_DATA_DIR, testDir);
const testCases = fs.readdirSync(testCaseDir).filter((file) => file.endsWith('.html'));
for (const testCase of testCases) {
test(
testCase,
async () => {
const check = (await checks).find((check) => check.id === testDir);
if (!check) {
fail(`no check with name ${testDir}`);
return;
test(testCase, async () => {
const check = (await checks).find((check) => check.id === testDir);
if (!check) {
fail(`no check with name ${testDir}`);
return;
}
const url = fileUrl(path.join(testCaseDir, testCase));
const result = await pageExperienceGuide.runChecks(url, check.id);
const resultString = JSON.stringify(result, null, 2);
const expectedResultPath = path.join(testCaseDir, testCase.replace('.html', '.json'));
if (CREATE_SNAPSHOT) {
fs.promises.writeFile(expectedResultPath, resultString, 'utf-8');
} else {
let expectedResult;
try {
expectedResult = await fs.promises.readFile(expectedResultPath, 'utf-8');
} catch (e) {
fail(`No expected results for ${testCase}. Run 'npm run test:snapshot' to generate.`);
}
const url = fileUrl(path.join(testCaseDir, testCase));
const result = await pageExperienceGuide.runChecks(url, check.id);
const resultString = JSON.stringify(result, null, 2);
const expectedResultPath = path.join(testCaseDir, testCase.replace('.html', '.json'));
if (CREATE_SNAPSHOT) {
fs.promises.writeFile(expectedResultPath, resultString, 'utf-8');
} else {
let expectedResult;
try {
expectedResult = await fs.promises.readFile(expectedResultPath, 'utf-8');
} catch (e) {
fail(`No expected results for ${testCase}. Run 'npm run test:snapshot' to generate.`);
}
expect(resultString).toEqual(expectedResult);
}
},
20000
);
expect(resultString).toEqual(expectedResult);
}
});
}
}
});
Expand Down

0 comments on commit a2b6cb8

Please sign in to comment.