mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
test: only intercept the page-data for tested page (#62042)
This commit is contained in:
committed by
GitHub
parent
ebd17c473b
commit
b47bc04c97
@@ -23,13 +23,15 @@ interface PageData {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const quizPath = '/learn/full-stack-developer/quiz-basic-html/quiz-basic-html';
|
||||||
|
|
||||||
test.describe('Quiz challenge', () => {
|
test.describe('Quiz challenge', () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
const fixturePath = path.join(__dirname, 'fixtures', 'quiz-fixture.json');
|
const fixturePath = path.join(__dirname, 'fixtures', 'quiz-fixture.json');
|
||||||
const fixture = JSON.parse(fs.readFileSync(fixturePath, 'utf8')) as Quiz[];
|
const fixture = JSON.parse(fs.readFileSync(fixturePath, 'utf8')) as Quiz[];
|
||||||
|
|
||||||
// Intercept Gatsby page-data and inject a deterministic quiz fixture
|
// Intercept Gatsby page-data and inject a deterministic quiz fixture
|
||||||
await page.route('**/page-data/**/page-data.json', async route => {
|
await page.route(`**/page-data${quizPath}/page-data.json`, async route => {
|
||||||
const response = await route.fetch();
|
const response = await route.fetch();
|
||||||
const body = await response.text();
|
const body = await response.text();
|
||||||
|
|
||||||
@@ -42,9 +44,7 @@ test.describe('Quiz challenge', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.goto(
|
await page.goto(quizPath);
|
||||||
'/learn/full-stack-developer/quiz-basic-html/quiz-basic-html'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should display a list of unanswered questions if user has not answered all questions', async ({
|
test('should display a list of unanswered questions if user has not answered all questions', async ({
|
||||||
|
|||||||
Reference in New Issue
Block a user