Skip to content

Commit

Permalink
test(Node.js): Use arrayContaining to reduce test brittleness
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Jun 17, 2021
1 parent 1efb6ff commit eaaa16d
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions node/src/projects.test.ts
Expand Up @@ -17,7 +17,9 @@ function fixture(folder: string) {
* Wait for a bit (usually for events), longer on CI (because that seems necessary).
*/
async function delay(milliseconds: number) {
await new Promise((resolve) => setTimeout(resolve, milliseconds * (process.env.CI ? 4 : 1)))
await new Promise((resolve) =>
setTimeout(resolve, milliseconds * (process.env.CI ? 4 : 1))
)
}

test('schema', () => {
Expand Down Expand Up @@ -109,19 +111,23 @@ test('workflow: open and modify', async () => {
// Wait for debounced filesystem events to propagate
await delay(500)

expect(projectEvents).toEqual([
expect.objectContaining({
type: 'updated',
project: expect.objectContaining({
path: folder,
theme: 'wilmore',
expect(projectEvents).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'updated',
project: expect.objectContaining({
path: folder,
theme: 'wilmore',
}),
}),
}),
])
expect(fileEvents).toEqual([
expect.objectContaining({
type: 'created',
path: path.join(folder, 'project.json'),
}),
])
])
)
expect(fileEvents).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'created',
path: path.join(folder, 'project.json'),
}),
])
)
})

0 comments on commit eaaa16d

Please sign in to comment.