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
10 changes: 10 additions & 0 deletions packages/vitest/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ export default ({ watch }) =>
}
},
},
{
// rollup-plugin-dts drops reference directives of .ts sources,
// so every chunk that uses the global `Chai` namespace loads @types/chai here
name: 'vitest-chai-type-reference',
renderChunk(code) {
if (/\bChai\./.test(code)) {
return `/// <reference types="chai" />\n${code}`
}
},
},
],
},
])
Expand Down
220 changes: 220 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions test/e2e/dts/chai-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@vitest/test-integration-dts-chai-types",
"type": "module",
"private": true,
"scripts": {
"test": "pnpm test:ts5 && pnpm test:ts7",
"test:ts5": "node node_modules/typescript/bin/tsc -b --force tsconfig.json tsconfig.runtime.json",
"test:ts7": "node node_modules/typescript-7/bin/tsc -b --force tsconfig.json tsconfig.runtime.json"
},
"devDependencies": {
"typescript": "catalog:",
"typescript-7": "npm:typescript@^7.0.2",
"vitest": "workspace:*"
}
}
11 changes: 11 additions & 0 deletions test/e2e/dts/chai-types/src/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Environment } from 'vitest/runtime'

export default <Environment>{
name: 'custom',
viteEnvironment: 'ssr',
setup() {
return {
teardown() {},
}
},
}
11 changes: 11 additions & 0 deletions test/e2e/dts/chai-types/src/expect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { assert, expect, test } from 'vitest'

test('chai api', async () => {
expect('a').not.toBe('b')
expect(1).to.equal(1)
expect([1, 2]).to.not.include(3)
expect({ a: 1 }).to.have.property('a').that.is.a('number')
expect.soft(1).not.toBe(2)
await expect(Promise.resolve(1)).resolves.not.toBe(2)
assert.strictEqual(1, 1)
})
13 changes: 13 additions & 0 deletions test/e2e/dts/chai-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": ["../_shared/tsconfig.patch.json"],
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": [],
"strict": true,
"noEmit": true,
"skipLibCheck": false
},
"include": ["src/expect.ts"]
}
4 changes: 4 additions & 0 deletions test/e2e/dts/chai-types/tsconfig.runtime.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src/environment.ts"]
}
3 changes: 2 additions & 1 deletion test/e2e/dts/exact-optional-property-no-node/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"declarationMap": true,
"sourceMap": true,
"verbatimModuleSyntax": true,
"skipLibCheck": false
"skipLibCheck": false,
"noEmit": true
}
}