Skip to content

Commit ea16297

Browse files
committed
test: add a test project and build it as part of the test script
1 parent 6c8fc30 commit ea16297

File tree

12 files changed

+1094
-77
lines changed

12 files changed

+1094
-77
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
with:
3030
node-version: ${{matrix.node-version}}
3131
- run: yarn
32-
- run: yarn test
32+
- run: yarn test-projects
3333
- run: yarn lint
3434
deploy:
3535
name: Deploy
3636
runs-on: ubuntu-latest
37-
needs: build-and-test
37+
needs: build-and-test-projects
3838
steps:
3939
- name: Find yarn cache
4040
id: find-yarn-cache

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/.idea/workspace.xml
22
/.idea/tasks.xml
33
/.idea/shelf
4-
/node_modules
4+
node_modules
5+
dist
56
package-lock.json
67
yarn-error.log
78
npm-debug.log*

index.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
import {fork} from "child_process";
2+
import {resolve} from "path";
13
import test from "ava";
24

3-
test("placeholder test", t => t.true(true));
5+
async function buildTestProject(path: string): Promise<void> {
6+
return yarn(path, [])
7+
.then(code => code === 0 ? yarn(path, ["build"]) : code)
8+
.then(code => {
9+
if (code !== 0) {
10+
throw new Error("Build exited with error status");
11+
}
12+
});
13+
}
14+
15+
async function yarn(path: string, args: readonly string[]): Promise<number> {
16+
const fullPath = resolve(__dirname, path);
17+
return new Promise((resolve, reject) => fork(require.resolve("yarn/bin/yarn.js"), args, {cwd: fullPath})
18+
.on("error", reject)
19+
.on("exit", (code, signal) => code == null ? reject(signal) : resolve(code)));
20+
}
21+
22+
test("type-module-config-cjs-import-js", async t => {
23+
await buildTestProject("test-projects/type-module-config-cjs-import-js");
24+
t.pass();
25+
})

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@
3939
"@softwareventures/prettier-config": "2.0.0",
4040
"@softwareventures/semantic-release-config": "2.0.0",
4141
"@softwareventures/tsconfig": "5.1.0",
42+
"@types/node": "16.11.7",
4243
"ava": "4.0.1",
4344
"cz-conventional-changelog": "3.3.0",
4445
"eslint": "7.32.0",
4546
"prettier": "2.5.1",
4647
"semantic-release": "17.4.7",
4748
"ts-node": "10.4.0",
4849
"typescript": "4.5.4",
49-
"webpack": "5.66.0"
50+
"webpack": "5.66.0",
51+
"yarn": "1.22.17"
5052
},
5153
"eslintConfig": {
5254
"root": true,
@@ -64,7 +66,8 @@
6466
],
6567
"require": [
6668
"ts-node/register/files"
67-
]
69+
],
70+
"timeout": "10m"
6871
},
6972
"release": {
7073
"extends": "@softwareventures/semantic-release-config"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import {test} from "./test.js"
2+
3+
test();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@softwareventures/resolve-typescript-plugin-test-1",
3+
"type": "module",
4+
"license": "ISC",
5+
"exports": {
6+
".": "./index.js"
7+
},
8+
"types": "index.d.ts",
9+
"scripts": {
10+
"build": "webpack"
11+
},
12+
"dependencies": {
13+
"tslib": "2.3.1"
14+
},
15+
"devDependencies": {
16+
"@softwareventures/tsconfig": "5.1.0",
17+
"resolve-typescript-plugin": "../..",
18+
"ts-loader": "9.2.6",
19+
"typescript": "4.5.4",
20+
"webpack": "5.66.0",
21+
"webpack-cli": "4.9.1"
22+
}
23+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export function test(): void {
2+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "@softwareventures/tsconfig",
3+
"compilerOptions": {
4+
"declaration": false
5+
}
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const ResolveTypeScriptPlugin = require("resolve-typescript-plugin");
2+
3+
module.exports = {
4+
mode: "production",
5+
context: __dirname,
6+
entry: "./index.js",
7+
module: {
8+
rules: [
9+
{
10+
test: /\.tsx?$/,
11+
use: "ts-loader"
12+
}
13+
]
14+
},
15+
resolve: {
16+
plugins: [new ResolveTypeScriptPlugin()]
17+
}
18+
};

0 commit comments

Comments
 (0)