Skip to content

Commit

Permalink
test(conditions): adding test that fails on vite6 without this change
Browse files Browse the repository at this point in the history
  • Loading branch information
thebanjomatic committed Jan 15, 2025
1 parent c0a7cb7 commit 0c8dad1
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/config/fixtures/conditions-subpackage/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'module'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { test, expect } from 'vitest';
import condition from './dependency';

test('condition is correct', () => {
expect(condition).toBe(TEST_CONDITION)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error('Should not be imported')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'module'
1 change: 1 addition & 0 deletions test/config/fixtures/default-conditions/dependency/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'node'
12 changes: 12 additions & 0 deletions test/config/fixtures/default-conditions/dependency/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "dependency",
"private": true,
"type": "module",
"exports": {
".": {
"module": "./module.js",
"node": "./node.js",
"default": "./default.js"
}
}
}
3 changes: 3 additions & 0 deletions test/config/fixtures/default-conditions/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({})
20 changes: 20 additions & 0 deletions test/config/test/default-conditions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { expect, test } from 'vitest'
import { runVitest } from '../../test-utils'

test('correctly imports "module" dependency with default resolve.conditions', async () => {
// dev condition is the default
const { stderr } = await runVitest({
root: 'fixtures/default-conditions',
server: {
deps: {
external: [/dependency/],
},
},
}, [], 'test', {
define: {
TEST_CONDITION: '"module"',
},
})

expect(stderr).toBe('')
})

0 comments on commit 0c8dad1

Please sign in to comment.