Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/expect/src/jest-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ function isObjectWithKeys(a: any) {
&& !(a instanceof Error)
&& !Array.isArray(a)
&& !(a instanceof Date)
&& !(a instanceof Set)
&& !(a instanceof Map)
)
}

Expand Down
3 changes: 3 additions & 0 deletions packages/vitest/src/node/plugins/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export function WorkspaceVitestPlugin(
if (testConfig.experimental?.nodeLoader == null && project.vitest.config.experimental?.nodeLoader != null) {
vitestConfig.experimental.nodeLoader = project.vitest.config.experimental.nodeLoader
}
if (testConfig.experimental?.importDurations == null && project.vitest.config.experimental?.importDurations != null) {
vitestConfig.experimental.importDurations = project.vitest.config.experimental.importDurations
}

return {
base: '/',
Expand Down
11 changes: 11 additions & 0 deletions test/config/test/cli-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ it('correctly inherit from the cli', async () => {
testNamePattern: 'math',
passWithNoTests: true,
bail: 100,
experimental: {
importDurations: {
print: true,
},
},
},
})
const project = ctx!.projects[0]
Expand All @@ -48,6 +53,12 @@ it('correctly inherit from the cli', async () => {
retry: 6,
passWithNoTests: true,
bail: 100,
experimental: expect.objectContaining({
importDurations: {
print: true,
limit: 10,
},
}),
})
expect(config.testNamePattern?.test('math')).toBe(true)
})
23 changes: 23 additions & 0 deletions test/core/test/jest-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,29 @@ function getError(f: () => unknown) {
return expect.unreachable()
}

it('toMatchObject', () => {
expect(() => expect(null).toMatchObject(new Set()))
.toThrowErrorMatchingInlineSnapshot(`[AssertionError: expected null to match object Set{}]`)
expect(() => expect(undefined).toMatchObject(new Set()))
.toThrowErrorMatchingInlineSnapshot(`[AssertionError: expected undefined to match object Set{}]`)
expect(() => expect(1234).toMatchObject(new Set()))
.toThrowErrorMatchingInlineSnapshot(`[AssertionError: expected 1234 to match object Set{}]`)
expect(() => expect('hello').toMatchObject(new Set()))
.toThrowErrorMatchingInlineSnapshot(`[AssertionError: expected 'hello' to match object Set{}]`)
expect(() => expect({}).toMatchObject(new Set()))
.toThrowErrorMatchingInlineSnapshot(`[AssertionError: expected {} to match object Set{}]`)
expect(() => expect({}).toMatchObject(new Map()))
.toThrowErrorMatchingInlineSnapshot(`[AssertionError: expected {} to match object Map{}]`)

// subset equality works inside Set/Map
expect(new Set([{ x: 1 }])).toMatchObject(new Set([{}]))
expect(new Map([[1, { a: 1 }]])).toMatchObject(new Map([[1, {}]]))

// Set/Map matches against empty object shape
expect(new Set()).toMatchObject({})
expect(new Map()).toMatchObject({})
})

it('toMatchObject error diff', () => {
// single property on root (3 total properties, 1 expected)
expect(getError(() => expect({ a: 1, b: 2, c: 3 }).toMatchObject({ c: 4 }))).toMatchInlineSnapshot(`
Expand Down
Loading