Skip to content

Commit

Permalink
fix: run vitest tests sequentially (#3698)
Browse files Browse the repository at this point in the history
fix: run vitest tests sequentially & fix flaky tests
  • Loading branch information
mariojsnunes committed Jun 28, 2024
1 parent d5182a6 commit 61ea2ad
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,4 @@
"node": ">=20"
},
"packageManager": "yarn@3.6.4"
}
}
3 changes: 3 additions & 0 deletions packages/components/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const vitestConfig: VitestUserConfigInterface = {
},
include: ['./src/**/*.test.?(c|m)[jt]s?(x)'],
logHeapUsage: true,
sequence: {
hooks: 'list',
},
},
}
// eslint-disable-next-line import/no-default-export
Expand Down
29 changes: 19 additions & 10 deletions src/pages/Research/Content/ResearchArticle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('Research Article', () => {

// Assert
await waitFor(() => {
expect(wrapper.getAllByText('With contributions from:')).toHaveLength(1)
expect(wrapper.getAllByText('With contributions from')).toHaveLength(1)
expect(wrapper.getAllByText('example-username')).toHaveLength(2)
expect(wrapper.getAllByText('another-example-username')).toHaveLength(2)
expect(wrapper.getAllByTestId('Username: known flag')).toHaveLength(4)
Expand Down Expand Up @@ -241,15 +241,24 @@ describe('Research Article', () => {
})

// Assert
await waitFor(() => {
expect(wrapper.getAllByText('With contributions from:')).toHaveLength(1)
expect(wrapper.getAllByText('example-username')).toHaveLength(2)
expect(wrapper.getAllByText('another-example-username')).toHaveLength(2)
expect(wrapper.getAllByText('third-example-username')).toHaveLength(1)
expect(wrapper.queryByText('fourth-example-username')).toBeNull()
expect(wrapper.getAllByTestId('collaborator/creator')).toHaveLength(1)
expect(wrapper.getAllByTestId('Username: known flag')).toHaveLength(5)
})
await waitFor(
() => {
expect(wrapper.getAllByText('With contributions from')).toHaveLength(
1,
)
expect(wrapper.getAllByText('example-username')).toHaveLength(2)
expect(wrapper.getAllByText('another-example-username')).toHaveLength(
2,
)
expect(wrapper.getAllByText('third-example-username')).toHaveLength(1)
expect(wrapper.queryByText('fourth-example-username')).toBeNull()
expect(wrapper.getAllByTestId('collaborator/creator')).toHaveLength(1)
expect(wrapper.getAllByTestId('Username: known flag')).toHaveLength(5)
},
{
timeout: 10000,
},
)
})

it('does not show edit timestamp, when create displays the same value', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/Maps/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('filterMapPinsByType', () => {

it('returns only verified pins', () => {
const mapPins: Partial<IMapPin>[] = [
{ _deleted: false, type: 'member', verified: true },
{ _deleted: false, type: 'collection-point', verified: true },
{ _deleted: false, type: 'machine-builder' },
]
expect(
Expand Down
5 changes: 1 addition & 4 deletions src/stores/Maps/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import type { IMapPin } from 'src/models/maps.models'

// filter pins to include matched pin type or subtype
// excluding items which have been marked as deleted=true
export const filterMapPinsByType = (
mapPins: IMapPin[],
filters: Array<string>,
) => {
export const filterMapPinsByType = (mapPins: IMapPin[], filters: string[]) => {
const filterList = new Set(filters)
let filteredPins = mapPins

Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const vitestConfig: VitestUserConfigInterface = {
},
include: ['./src/**/*.test.?(c|m)[jt]s?(x)'],
logHeapUsage: true,
sequence: {
hooks: 'list',
},
},
}

Expand Down

0 comments on commit 61ea2ad

Please sign in to comment.