Skip to content

Commit

Permalink
Merge pull request #19463 from storybookjs/add-json-files-e2e-test
Browse files Browse the repository at this point in the history
Add e2e test for static JSON files
  • Loading branch information
ndelangen authored Jan 13, 2023
2 parents cd99f77 + d120064 commit 07b2500
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions code/e2e-tests/json-files.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 }) => {
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': expect.objectContaining({
id: 'example-button--primary',
importPath: expect.stringContaining('Button.stories'),
name: 'Primary',
title: 'Example/Button',
type: 'story',
}),
}),
});
});
});

0 comments on commit 07b2500

Please sign in to comment.