Skip to content

Commit

Permalink
fix: cherry-pick vitest-dev#6896 to fix immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 13, 2024
1 parent ec1860b commit 2655bd5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
12 changes: 12 additions & 0 deletions packages/vitest/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ export async function VitestPlugin(
alias: testConfig.alias,
conditions: ['node'],
},
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore Vite 6 compat
environments: {
ssr: {
resolve: {
// by default Vite resolves `module` field, which not always a native ESM module
// setting this option can bypass that and fallback to cjs version
mainFields: [],
conditions: ['node'],
},
},
},
server: {
...testConfig.api,
open,
Expand Down
12 changes: 12 additions & 0 deletions packages/vitest/src/node/plugins/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ export function WorkspaceVitestPlugin(
alias: testConfig.alias,
conditions: ['node'],
},
// eslint-disable-next-line ts/ban-ts-comment
// @ts-ignore Vite 6 compat
environments: {
ssr: {
resolve: {
// by default Vite resolves `module` field, which not always a native ESM module
// setting this option can bypass that and fallback to cjs version
mainFields: [],
conditions: ['node'],
},
},
},
esbuild: viteConfig.esbuild === false
? false
: {
Expand Down
20 changes: 8 additions & 12 deletions test/core/test/immutable.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// import im from 'immutable'
// import { expect, test } from 'vitest'
import im from 'immutable'
import { expect, test } from 'vitest'

// test('basic', () => {
// expect(im.List([{ x: 1 }])).toEqual(im.List([{ x: 1 }]))
// expect(im.List([{ x: 1 }])).toEqual(im.List([1]).map(i => ({ x: i })))
// expect(im.List([{ x: 1 }])).not.toEqual(im.List([{ x: 2 }]))
// expect(im.List([{ x: 1 }])).not.toEqual(im.List([]))
// })

import { test } from 'vitest'

test('todo', () => {})
test('basic', () => {
expect(im.List([{ x: 1 }])).toEqual(im.List([{ x: 1 }]))
expect(im.List([{ x: 1 }])).toEqual(im.List([1]).map(i => ({ x: i })))
expect(im.List([{ x: 1 }])).not.toEqual(im.List([{ x: 2 }]))
expect(im.List([{ x: 1 }])).not.toEqual(im.List([]))
})

0 comments on commit 2655bd5

Please sign in to comment.