Skip to content

Commit

Permalink
added tests-pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
bumblehead committed Oct 18, 2024
1 parent 4a87be8 commit 649330e
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test-pnpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: pnpm/action-setup@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build --if-present
- run: npm run test-ci-pnpm
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"test:all": "cd tests && npm run test:all",
"test:all-ci": "cd tests && npm run test:all-ci",
"test": "npm run test:all",
"test-ci-pnpm": "cd tests && cd test-pnpm && pnpm i && npm run test",
"test-ci": "npm run test:install && npm run test:all-ci",
"test-cover": "npm run test:install && c8 npm run test:all",
"lint": "eslint .",
Expand Down
26 changes: 26 additions & 0 deletions tests/tests-pnpm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "scoped-package-mock",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/iambumblehead/esmock.git"
},
"scripts": {
"test-tsimp": "TSIMP_PROJECT=./test/tsconfig.json node --import tsimp/import --test-reporter spec --test 'test/example.test.ts'",
"test-tsx": "TSX_TSCONFIG_PATH=./test/tsconfig.json node --import tsx --test-reporter spec --test 'test/example.test.ts'",
"test-tsnode": "TS_NODE_PROJECT=./test/tsconfig.json node --import ./ts-node.register.mjs --test-reporter spec --test 'test/example.test.ts'",
"test": "npm run test-tsnode"
},
"dependencies": {
"@nestjs/core": "^10.3.8",
"@nestjs/platform-express": "^10.3.8"
},
"devDependencies": {
"@types/node": "^20.12.7",
"esmock": "file:..",
"ts-node": "^10.9.2",
"tsimp": "^2.0.11",
"tsx": "^4.9.3",
"typescript": "^5.4.5"
}
}
6 changes: 6 additions & 0 deletions tests/tests-pnpm/src/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { NestFactory } from "@nestjs/core"

export const example = async () => {
const test = await NestFactory.create({} as any)
console.log(test)
}
14 changes: 14 additions & 0 deletions tests/tests-pnpm/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
}
}
23 changes: 23 additions & 0 deletions tests/tests-pnpm/test/example.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, it } from "node:test"
import { equal } from "node:assert/strict"
import esmock from "esmock"

describe("Example", async () => {
it("Fails", async () => {
const { example } = await esmock(
"../src/example.js",
import.meta.url,
{
"@nestjs/core": {
NestFactory: {
create: async () => 'mocked'
}
}
}
)

await example()

equal(1,1)
})
})
10 changes: 10 additions & 0 deletions tests/tests-pnpm/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
}
}
6 changes: 6 additions & 0 deletions tests/tests-pnpm/ts-node.register.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// https://github.com/TypeStrong/ts-node/issues/2100

import { pathToFileURL } from "node:url"
import { register } from "node:module"

register("ts-node/esm", pathToFileURL("./"))

0 comments on commit 649330e

Please sign in to comment.