Skip to content

Commit

Permalink
🔊 Add more debug/tracing information for flaky tests
Browse files Browse the repository at this point in the history
Some CI errors are too cryptic, hopefully with this we can figure out which tests are
still failing sometimes.
  • Loading branch information
sergei-maertens committed Nov 13, 2023
1 parent 70fcd21 commit b1d7c2e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .storybook/decorators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export const withFormik = (Story: StoryFn, context: StoryContext) => {
onSubmit={(values, formikHelpers) => console.log(values, formikHelpers)}
>
{wrapForm ? (
<form>
<form id="storybook-withFormik-decorator-form">
<Story />
</form>
) : (
Expand Down
15 changes: 15 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {TestRunnerConfig} from '@storybook/test-runner';

const config: TestRunnerConfig = {
preRender: async (page, context) => {
const {id} = context;
console.log(`Testing story with id: ${id}`);
},

postRender: async (page, context) => {
const {id} = context;
console.log(`Done testing story with id: ${id}`);
},
};

export default config;
12 changes: 7 additions & 5 deletions src/registry/date/date-component.stories.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {expect} from '@storybook/jest';
import {Meta, StoryObj} from '@storybook/react';
import {userEvent, within} from '@storybook/testing-library';
import {userEvent, waitFor, within} from '@storybook/testing-library';

import ComponentEditForm from '@/components/ComponentEditForm';
import {withFormik} from '@/sb-decorators';

export default {
title: 'Builder components/DateField',
component: ComponentEditForm,
decorators: [withFormik],
parameters: {},
args: {
isNew: true,
Expand Down Expand Up @@ -42,7 +40,9 @@ export const ValidateDeltaConstraintConfiguration: Story = {
await step('Navigate to validation tab and open maxDate configuration', async () => {
await userEvent.click(canvas.getByRole('link', {name: 'Validation'}));
await userEvent.click(canvas.getByText(/Maximum date/));
expect(await canvas.findByText('Mode preset')).toBeVisible();
await waitFor(async () => {
expect(await canvas.findByText('Mode preset')).toBeVisible();
});
});

await step('Configure relative to variable', async () => {
Expand Down Expand Up @@ -74,7 +74,9 @@ export const ValidateDeltaConstraintConfiguration: Story = {
});

await step('Check the validation errors', async () => {
expect(await canvas.findByText(/The property name must only contain/)).toBeVisible();
await waitFor(async () => {
expect(await canvas.findByText(/The property name must only contain/)).toBeVisible();
});
expect(await canvas.findByText('Expected integer, received float')).toBeVisible();
expect(await canvas.findByText('Number must be greater than or equal to 0')).toBeVisible();
});
Expand Down

0 comments on commit b1d7c2e

Please sign in to comment.