Skip to content

Commit

Permalink
fix: fixes issue with tests not being found from template (#3605)
Browse files Browse the repository at this point in the history
fix [#3647](#3647)

With node 22 the --test needs a glob to find files to test. As the docs
a written the tests don't run or pass. This fixes it for me.

---------

Co-authored-by: Timothee Guerin <tiguerin@microsoft.com>
  • Loading branch information
jspears and timotheeguerin authored Jul 8, 2024
1 parent a38126c commit 245e4e6
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 34 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/fix-test-path-2024-6-5-14-0-33.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/compiler"
---

Fix templates initialized on node 22
3 changes: 2 additions & 1 deletion docs/extending-typespec/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ Alternatively, you can add these as scripts in your `package.json` to make them
"clean": "rimraf ./dist ./temp",
"build": "tsc -p .",
"watch": "tsc -p . --watch",
"test": "node --test ./dist/test"
"test": "node --test ./dist/test/**/*.test.js", // Node 22+
"test": "node --test ./dist/test/" // Node 18, 20
}
```

Expand Down
3 changes: 3 additions & 0 deletions eng/tsp-core/pipelines/stages/ci-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ stages:
"Node 20.x":
nodeVersion: 20.x

"Node 22.x":
nodeVersion: 22.x

pool:
name: $(WINDOWSPOOL)
image: $(WINDOWSVMIMAGE)
Expand Down
14 changes: 0 additions & 14 deletions packages/compiler/templates/__snapshots__/emitter-ts/.eslintrc.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check
import eslint from "@eslint/js";
import tsEslint from "typescript-eslint";

export default tsEslint.config(
{
ignores: ["**/dist/**/*", "**/.temp/**/*"],
},
eslint.configs.recommended,
...tsEslint.configs.recommended
);
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"build": "tsc",
"watch": "tsc --watch",
"test": "node --test ./dist/test/",
"test": "node --test",
"lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0",
"lint:fix": "eslint . --report-unused-disable-directives --fix",
"format": "prettier . --write",
Expand Down
14 changes: 0 additions & 14 deletions packages/compiler/templates/__snapshots__/library-ts/.eslintrc.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check
import eslint from "@eslint/js";
import tsEslint from "typescript-eslint";

export default tsEslint.config(
{
ignores: ["**/dist/**/*", "**/.temp/**/*"],
},
eslint.configs.recommended,
...tsEslint.configs.recommended
);
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build": "tsc && npm run build:tsp",
"watch": "tsc --watch",
"build:tsp": "tsp compile . --warn-as-error --import @typespec/library-linter --no-emit",
"test": "node --test ./dist/test/",
"test": "node --test",
"lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0",
"lint:fix": "eslint . --report-unused-disable-directives --fix",
"format": "prettier . --write",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/templates/emitter-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"scripts": {
"build": "tsc",
"watch": "tsc --watch",
"test": "node --test ./dist/test/",
"test": "node --test",
"lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0",
"lint:fix": "eslint . --report-unused-disable-directives --fix",
"format": "prettier . --write",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/templates/library-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build": "tsc && npm run build:tsp",
"watch": "tsc --watch",
"build:tsp": "tsp compile . --warn-as-error --import @typespec/library-linter --no-emit",
"test": "node --test ./dist/test/",
"test": "node --test",
"lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0",
"lint:fix": "eslint . --report-unused-disable-directives --fix",
"format": "prettier . --write",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Alternatively, you can add these as scripts in your `package.json` to make them
"clean": "rimraf ./dist ./temp",
"build": "tsc -p .",
"watch": "tsc -p . --watch",
"test": "node --test ./dist/test"
"test": "node --test ./dist/test/**/*.test.js",
}
```

Expand Down

0 comments on commit 245e4e6

Please sign in to comment.