Skip to content

Commit cceb28c

Browse files
committed
add ts smoke tests
1 parent 3c37bb0 commit cceb28c

File tree

10 files changed

+68
-0
lines changed

10 files changed

+68
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ jobs:
3636
run: yarn install
3737
- name: Run Tests
3838
run: yarn test
39+
- name: Run TS Smoke Tests
40+
run: yarn test:ts

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"prepublish": "yarn build",
5050
"build": "rimraf dist && tsc",
5151
"test": "jest",
52+
"test:ts": "node test/ts-tests/run-tests.mjs",
5253
"prerelease": "yarn build",
5354
"release": "changeset publish",
5455
"release:canary": "node scripts/canary-release.js && yarn build && yarn changeset publish --tag alpha"

test/ts-tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test.js

test/ts-tests/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

test/ts-tests/run-tests.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import execa from "execa";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = path.dirname(__filename);
7+
8+
async function run(commandStr) {
9+
const [command, ...args] = commandStr.split(" ");
10+
await execa(command, args);
11+
}
12+
13+
async function main() {
14+
await run(`rm -rf ${__dirname}/node_modules`);
15+
await run(`mkdir -p ${__dirname}/node_modules`);
16+
await run(
17+
`ln -s ${__dirname}/../__fixtures__/simple/dist ${__dirname}/node_modules/simple`
18+
);
19+
await run(`yarn tsc --project ${__dirname}/tsconfig.commonjs-node16.json`);
20+
await run(`yarn tsc --project ${__dirname}/tsconfig.commonjs-nodenext.json`);
21+
await run(`yarn tsc --project ${__dirname}/tsconfig.node16-node16.json`);
22+
await run(`yarn tsc --project ${__dirname}/tsconfig.nodenext-nodenext.json`);
23+
}
24+
25+
main();

test/ts-tests/test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import kek from "simple";
2+
import { someNumber } from "simple";
3+
4+
console.log(`${kek} ${someNumber}`);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"include": ["test.ts"],
3+
"compilerOptions": {
4+
"strict": true,
5+
"module": "CommonJS",
6+
"moduleResolution": "Node16"
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"include": ["test.ts"],
3+
"compilerOptions": {
4+
"strict": true,
5+
"module": "CommonJS",
6+
"moduleResolution": "NodeNext"
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"include": ["test.ts"],
3+
"compilerOptions": {
4+
"strict": true,
5+
"module": "Node16",
6+
"moduleResolution": "Node16"
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"include": ["test.ts"],
3+
"compilerOptions": {
4+
"strict": true,
5+
"module": "NodeNext",
6+
"moduleResolution": "NodeNext"
7+
}
8+
}

0 commit comments

Comments
 (0)