Skip to content

Commit bbfcf9f

Browse files
committed
test: add more test
1 parent d0f42b0 commit bbfcf9f

File tree

12 files changed

+227
-25
lines changed

12 files changed

+227
-25
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default antfu(
2323
'test/network-imports/public/[email protected]',
2424
'test/coverage-test/src/transpiled.js',
2525
'test/coverage-test/src/original.ts',
26-
'test/cli/deps/error/index.js',
26+
'test/cli/deps/error/*',
2727
'examples/**/mockServiceWorker.js',
2828
'examples/sveltekit/.svelte-kit',
2929
'packages/browser/**/esm-client-injector.js',

test/cli/deps/error/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'node:path'
22

3-
export function testStack() {
3+
export default function testStack() {
44
innerTestStack()
55
}
66

test/cli/deps/error/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"name": "@vitest/test-dep-error",
33
"type": "module",
44
"private": true,
5-
"exports": "./index.js"
5+
"exports": {
6+
".": "./index.js",
7+
"./*": "./*"
8+
}
69
}

test/cli/deps/error/transpiled-inline.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'node:path'
2+
3+
export type Dummy = {
4+
foo: "foo",
5+
}
6+
7+
/**
8+
* dummy
9+
* dummy
10+
*/
11+
export default function testStack() {
12+
innerTestStack()
13+
}
14+
15+
import 'node:util'
16+
17+
/**
18+
* bar
19+
* bar
20+
*/
21+
function innerTestStack() {
22+
throw new Error('__TEST_STACK_TRANSPILED_INLINE__')
23+
}
24+
25+
// transpiled-inline.js is copied from
26+
// https://esbuild.github.io/try/#dAAwLjI1LjAALS1sb2FkZXI9dHMgLS1zb3VyY2VtYXA9aW5saW5lIC0tc291cmNlZmlsZT10cmFuc3BpbGVkLWlubGluZS50cwBpbXBvcnQgJ25vZGU6cGF0aCcKCmV4cG9ydCB0eXBlIER1bW15ID0gewogIGZvbzogImZvbyIsCn0KCi8qKgogKiBkdW1teQogKiBkdW1teQogKi8KZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdGVzdFN0YWNrKCkgewogIGlubmVyVGVzdFN0YWNrKCkKfQoKaW1wb3J0ICdub2RlOnV0aWwnCgovKioKICogYmFyCiAqIGJhcgogKi8KZnVuY3Rpb24gaW5uZXJUZXN0U3RhY2soKSB7CiAgdGhyb3cgbmV3IEVycm9yKCdfX1RFU1RfU1RBQ0tfVFJBTlNQSUxFRF9JTkxJTkVfXycpCn0

test/cli/deps/error/transpiled.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/deps/error/transpiled.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/deps/error/transpiled.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'node:path'
2+
3+
export type Dummy = {
4+
foo: "foo",
5+
}
6+
7+
/**
8+
* dummy
9+
* dummy
10+
*/
11+
export default function testStack() {
12+
innerTestStack()
13+
}
14+
15+
import 'node:util'
16+
17+
/**
18+
* bar
19+
* bar
20+
*/
21+
function innerTestStack() {
22+
throw new Error('__TEST_STACK_TRANSPILED__')
23+
}
24+
25+
// transpiled.js and transpiled.js.map are copied from
26+
// https://esbuild.github.io/try/#dAAwLjI1LjAALS1sb2FkZXI9dHMgLS1zb3VyY2VtYXAgLS1zb3VyY2VmaWxlPXRyYW5zcGlsZWQudHMAaW1wb3J0ICdub2RlOnBhdGgnCgpleHBvcnQgdHlwZSBEdW1teSA9IHsKICBmb286ICJmb28iLAp9CgovKioKICogZHVtbXkKICogZHVtbXkKICovCmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIHRlc3RTdGFjaygpIHsKICBpbm5lclRlc3RTdGFjaygpCn0KCmltcG9ydCAnbm9kZTp1dGlsJwoKLyoqCiAqIGJhcgogKiBiYXIKICovCmZ1bmN0aW9uIGlubmVyVGVzdFN0YWNrKCkgewogIHRocm93IG5ldyBFcnJvcignX19URVNUX1NUQUNLX1RSQU5TUElMRURfXycpCn0

test/cli/deps/error/ts.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'node:path'
2+
3+
export type Dummy = {
4+
foo: "foo",
5+
}
6+
7+
/**
8+
* dummy
9+
* dummy
10+
*/
11+
export default function testStack() {
12+
innerTestStack()
13+
}
14+
15+
import 'node:util'
16+
17+
/**
18+
* bar
19+
* bar
20+
*/
21+
function innerTestStack() {
22+
throw new Error('__TEST_STACK_TS__')
23+
}
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import { test } from 'vitest'
2-
import { testStack } from "@vitest/test-dep-error"
2+
import testStack from "@vitest/test-dep-error"
3+
import testStackTs from "@vitest/test-dep-error/ts.ts"
4+
import testStackTranspiled from "@vitest/test-dep-error/transpiled.js"
5+
import testStackTranspiledInline from "@vitest/test-dep-error/transpiled-inline.js"
36

4-
test('error in package', () => {
7+
test('js', () => {
58
testStack()
69
})
10+
11+
test('ts', () => {
12+
testStackTs()
13+
})
14+
15+
test('transpiled', () => {
16+
testStackTranspiled()
17+
})
18+
19+
test('transpiled inline', () => {
20+
testStackTranspiledInline()
21+
})

0 commit comments

Comments
 (0)