fix: run vitest tests sequentially (#3698)

fix: run vitest tests sequentially & fix flaky tests
This commit is contained in:
Mário Nunes
2024-06-28 14:51:26 +07:00
committed by GitHub
parent d5182a6313
commit 61ea2ad970
6 changed files with 28 additions and 16 deletions

View File

@@ -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

View File

@@ -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)
@@ -241,15 +241,24 @@ describe('Research Article', () => {
})
// Assert
await waitFor(() => {
expect(wrapper.getAllByText('With contributions from:')).toHaveLength(1)
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('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 () => {

View File

@@ -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(

View File

@@ -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

View File

@@ -25,6 +25,9 @@ const vitestConfig: VitestUserConfigInterface = {
},
include: ['./src/**/*.test.?(c|m)[jt]s?(x)'],
logHeapUsage: true,
sequence: {
hooks: 'list',
},
},
}