Skip to content

Commit bc45ad2

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

10 files changed

+75
-0
lines changed

Diff for: .github/workflows/ci.yaml

+2
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

Diff for: package.json

+1
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"

Diff for: test/ts-tests/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

Diff for: test/ts-tests/run-tests.mjs

+25
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();

Diff for: test/ts-tests/test.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const simple_1 = __importDefault(require("simple"));
7+
const simple_2 = require("simple");
8+
console.log(`${simple_1.default} ${simple_2.someNumber}`);

Diff for: test/ts-tests/test.ts

+4
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}`);

Diff for: test/ts-tests/tsconfig.commonjs-node16.json

+8
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+
}

Diff for: test/ts-tests/tsconfig.commonjs-nodenext.json

+8
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+
}

Diff for: test/ts-tests/tsconfig.node16-node16.json

+8
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+
}

Diff for: test/ts-tests/tsconfig.nodenext-nodenext.json

+8
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)