Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e test for static JSON files #19463

Merged
merged 6 commits into from
Jan 13, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions code/e2e-tests/json-files.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { test, expect } from '@playwright/test';
import process from 'process';

const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001';

test.describe('JSON files', () => {
test.beforeEach(async ({ page }) => {
await page.goto(storybookUrl);
});

test('should have index.json', async ({ page }) => {
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
// eslint-disable-next-line jest/valid-expect-in-promise
const json = await page.evaluate(() => fetch('/index.json').then((res) => res.json()));

expect(json).toEqual({
v: expect.any(Number),
entries: expect.objectContaining({
'example-button--primary': {
id: 'example-button--primary',
importPath: expect.stringMatching(/\/Button\.stories\.[tj]sx?$/),
name: 'Primary',
title: 'Example/Button',
type: 'story',
},
}),
});
});
});