Skip to content

Commit bd847bf

Browse files
authored
feat: test runtime support (#429)
1 parent 87a2b98 commit bd847bf

File tree

84 files changed

+17447
-1726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+17447
-1726
lines changed

.github/workflows/build.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,30 @@ jobs:
4444
nvm install $(cat test-workspaces/nvm/.nvmrc)
4545
nvm install lts/*
4646
47+
- name: Update NPM (Linux)
48+
if: runner.os == 'Linux'
49+
run: |
50+
sudo npm uninstall -g yarn pnpm
51+
sudo npm install -g npm@latest
52+
sudo npm install -g corepack@latest
53+
- name: Update NPM (Win/MacOS)
54+
if: runner.os != 'Linux'
55+
run: |
56+
npm uninstall -g yarn pnpm
57+
npm install -g npm@latest
58+
npm install -g corepack@latest
59+
- name: Uninstall old yarn (MacOS)
60+
if: runner.os == 'macOS'
61+
run: |
62+
rm -rf "$HOME/.yarn"
63+
4764
- name: Install dependencies
4865
run: |
66+
corepack enable
67+
corepack prepare yarn@latest --activate
4968
node --version
5069
npm --version
70+
yarn --version
5171
npm install
5272
5373
- name: Compile
@@ -68,7 +88,10 @@ jobs:
6888
- name: Pack for VSIX Tests
6989
run: npm run package:test
7090
env:
71-
TEST_TEMP: ${{ runner.temp }}
91+
TEST_TEMP: ${{ runner.temp }}
92+
93+
- name: Recompile-tests
94+
run: npm run compile:test
7295

7396
- name: Run VSIX Tests (Linux)
7497
run: xvfb-run -a npm run test:vsix

.github/workflows/publish.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,27 @@ jobs:
2424
with:
2525
node-version: lts/*
2626

27+
- name: Update NPM (Linux)
28+
if: runner.os == 'Linux'
29+
run: |
30+
sudo npm uninstall -g yarn pnpm
31+
sudo npm install -g npm@latest
32+
sudo npm install -g corepack@latest
33+
- name: Update NPM (Win/MacOS)
34+
if: runner.os != 'Linux'
35+
run: |
36+
npm uninstall -g yarn pnpm
37+
npm install -g npm@latest
38+
npm install -g corepack@latest
39+
2740
- name: Install dependencies
28-
run: npm install
41+
run: |
42+
corepack enable
43+
corepack prepare yarn@latest --activate
44+
node --version
45+
npm --version
46+
yarn --version
47+
npm install
2948
3049
- name: Build and Package
3150
run: npm run package:release

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ This extension automatically discovers and works with the `.mocharc.js/cjs/yaml/
2929

3030
- `mocha-vscode.env`: Additional environment variables set when executing tests. This is useful for setting things like `NODE_ENV`.
3131

32+
- `mocha-vscode.runtime`: The runtime to use for test discovery and execution.
33+
34+
- `mocha-vscode.custom-runtime`: The command and arguments to launch the runtime. Needs to be compatible with `node` arguments.
35+
3236
## Features
3337

3438
### Show, Running and Debugging Tests
@@ -47,6 +51,22 @@ To discover tests this extension dynamically translates your TypeScript or ESM c
4751

4852
For execution this extension will try to call directly the Mocha executable passing the `.mocharc` and additional arguments to it.
4953

54+
### Test Runtime
55+
56+
To discover and execute tests this extension executes inline scripts via a node-compatible runtime. Via these scripts the mocha conffiguration is loaded and test execution is started.
57+
58+
The runtime is auto-detected by default and it will use the respective commands automatically. The runtime can also be manually configured.
59+
60+
Supported runtimes:
61+
62+
* Node.js using `node` commands.
63+
* Node Version Manager using `nvm` commands.
64+
* Node.js using `yarn` commands (to support strategies like [PnP](https://yarnpkg.com/features/pnp))
65+
* Node Version Manager using `nvm` to launch `yarn` commands
66+
67+
You can also configure custom commands to be used via the VS Code settings.
68+
This allows using alternative runtimes which are not supported out-of-the-box. The binary needs to support the same arguments like node for launching scripts.
69+
5070
## Troubleshooting
5171

5272
### Check if Mocha itself works

biome.jsonc

Lines changed: 64 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,68 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3-
"files": {
4-
"include": ["src/**"],
5-
"ignore": ["out", "test-workspaces", "node_modules", "test-results", ".vscode-test", "tmp", "typings"]
6-
},
2+
"$schema": "https://biomejs.dev/schemas/2.3.0/schema.json",
3+
"files": {
4+
"includes": [
5+
"src/**",
6+
"scripts/**",
7+
"!out",
8+
"!test-workspaces",
9+
"!node_modules",
10+
"!test-results",
11+
"!.vscode-test",
12+
"!tmp",
13+
"!typings",
14+
"!src/typings"
15+
]
16+
},
17+
"formatter": {
18+
"enabled": true,
19+
"formatWithErrors": true,
20+
"attributePosition": "auto",
21+
"indentStyle": "space",
22+
"indentWidth": 2,
23+
"lineWidth": 120,
24+
"lineEnding": "lf"
25+
},
26+
"linter": {
27+
"enabled": true,
28+
"rules": {
29+
"style": {
30+
"noNonNullAssertion": "off", // we use these assertions
31+
"noParameterAssign": "off", // useful for default values
32+
"useBlockStatements": {
33+
"level": "error",
34+
"fix": "safe",
35+
"options": {}
36+
},
37+
"useEnumInitializers": "off"
38+
},
39+
"suspicious": {
40+
"noExplicitAny": "off" // used in areas where we work with dynamic JSON data
41+
},
42+
"correctness": {
43+
"noUnusedImports": {
44+
"level": "error",
45+
"fix": "safe",
46+
"options": {}
47+
},
48+
"noSwitchDeclarations": "off"
49+
}
50+
}
51+
},
52+
"javascript": {
53+
"formatter": {
54+
"arrowParentheses": "asNeeded",
55+
"bracketSameLine": true,
56+
"bracketSpacing": true,
57+
"quoteProperties": "asNeeded",
58+
"semicolons": "always",
59+
"trailingCommas": "none",
60+
"quoteStyle": "single"
61+
}
62+
},
63+
"json": {
764
"formatter": {
8-
"enabled": true,
9-
"formatWithErrors": true,
10-
"ignore": [],
11-
"attributePosition": "auto",
12-
"indentStyle": "space",
13-
"indentWidth": 4,
14-
"lineWidth": 120,
15-
"lineEnding": "lf"
16-
},
17-
"linter": {
18-
"enabled": true,
19-
"rules": {
20-
"style": {
21-
"noNonNullAssertion": "off", // we use these assertions
22-
"noParameterAssign": "off", // useful for default values
23-
"useBlockStatements": {
24-
"level": "error",
25-
"fix": "safe"
26-
},
27-
"useEnumInitializers": "off"
28-
},
29-
"suspicious": {
30-
"noExplicitAny": "off" // used in areas where we work with dynamic JSON data
31-
},
32-
"correctness": {
33-
"noUnusedImports": {
34-
"level": "error",
35-
"fix": "safe"
36-
},
37-
"noSwitchDeclarations": "off"
38-
}
39-
}
40-
},
41-
"organizeImports": {
42-
"enabled": true
43-
},
44-
"javascript": {
45-
"formatter": {
46-
"arrowParentheses": "asNeeded",
47-
"bracketSameLine": true,
48-
"bracketSpacing": true,
49-
"quoteProperties": "asNeeded",
50-
"semicolons": "always",
51-
"trailingCommas": "none",
52-
"quoteStyle": "single"
53-
}
54-
},
55-
"json": {
56-
"formatter": {
57-
"trailingCommas": "none"
58-
}
65+
"trailingCommas": "none"
5966
}
67+
}
6068
}

0 commit comments

Comments
 (0)