-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from iambumblehead/resolve-pnpm-issue
escape + char at regexp to resolve pnpn issue
- Loading branch information
Showing
10 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: test-pnpm | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test-pnpm: | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 12 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [22.x] | ||
os: [ubuntu-latest] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
- run: npm install | ||
- run: npm run build --if-present | ||
- run: npm run test-ci-pnpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "scoped-package-mock", | ||
"type": "module", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/iambumblehead/esmock.git" | ||
}, | ||
"description": "careful using this and rm -rf. pnpm does not support local file install :|", | ||
"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'", | ||
"node_modules-esmock:rm": "rm -r node_modules/esmock", | ||
"node_modules-esmock:link": "ln -s ../../ node_modules/esmock", | ||
"node_modules-esmock": "npm run node_modules-esmock:rm && npm run node_modules-esmock:link", | ||
"test": "npm run node_modules-esmock && npm run test-tsnode" | ||
}, | ||
"dependencies": { | ||
"@nestjs/core": "^10.3.8", | ||
"@nestjs/platform-express": "^10.3.8" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.12.7", | ||
"ts-node": "^10.9.2", | ||
"tsimp": "^2.0.11", | ||
"esmock": "latest", | ||
"tsx": "^4.9.3", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { NestFactory } from "@nestjs/core" | ||
|
||
export const example = async () => { | ||
const test = await NestFactory.create({} as any) | ||
console.log(test) | ||
return test | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { describe, it } from "node:test" | ||
import { equal } from "node:assert/strict" | ||
import esmock from "esmock" | ||
|
||
describe("Example", async () => { | ||
it("Mocks scoped module", async () => { | ||
const { example } = await esmock( | ||
"../src/example.js", | ||
import.meta.url, | ||
{ | ||
"@nestjs/core": { | ||
NestFactory: { | ||
create: async () => 'mocked' | ||
} | ||
} | ||
} | ||
) | ||
|
||
equal(await example(), 'mocked') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("./")) |