Skip to content

Commit c7eb370

Browse files
author
Alex Plischke
authored
feat: enable use of global node context (#270)
1 parent 2b5e308 commit c7eb370

File tree

5 files changed

+62
-18
lines changed

5 files changed

+62
-18
lines changed

package-lock.json

+46-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"dotenv": "16.4.5",
3838
"lodash": "4.17.21",
3939
"playwright": "1.45.2",
40-
"sauce-testrunner-utils": "3.0.0",
40+
"sauce-testrunner-utils": "3.1.0",
4141
"xml-js": "1.6.11"
4242
},
4343
"devDependencies": {

src/cucumber-runner.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { prepareNpmEnv, preExec } from 'sauce-testrunner-utils';
55

66
import type { CucumberRunnerConfig } from './types';
77
import * as utils from './utils';
8+
import { NodeContext } from 'sauce-testrunner-utils/lib/types';
89

910
function buildArgs(runCfg: CucumberRunnerConfig, cucumberBin: string) {
1011
const paths: string[] = [];
@@ -88,7 +89,11 @@ export async function runCucumber(
8889
'bin',
8990
'npm-cli.js',
9091
);
91-
const nodeCtx = { nodePath: nodeBin, npmPath: npmBin };
92+
const nodeCtx: NodeContext = {
93+
nodePath: nodeBin,
94+
npmPath: npmBin,
95+
useGlobals: !!runCfg.nodeVersion,
96+
};
9297

9398
// Install NPM dependencies
9499
await prepareNpmEnv(runCfg, nodeCtx);

src/playwright-runner.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import * as convert from 'xml-js';
1818
import { runCucumber } from './cucumber-runner';
1919
import type { CucumberRunnerConfig, RunnerConfig } from './types';
2020
import * as utils from './utils';
21+
import { NodeContext } from 'sauce-testrunner-utils/lib/types';
2122

2223
function getPlatformName(platformName: string) {
2324
if (process.platform.toLowerCase() === 'linux') {
@@ -359,7 +360,11 @@ async function runPlaywright(
359360
'bin',
360361
'npm-cli.js',
361362
);
362-
const nodeCtx = { nodePath: nodeBin, npmPath: npmBin };
363+
const nodeCtx: NodeContext = {
364+
nodePath: nodeBin,
365+
npmPath: npmBin,
366+
useGlobals: !!runCfg.nodeVersion,
367+
};
363368

364369
// runCfg.path must be set for prepareNpmEnv to find node_modules. :(
365370
await prepareNpmEnv(runCfg, nodeCtx);

src/types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export interface RunnerConfig {
1818
version: string;
1919
};
2020

21+
nodeVersion?: string;
22+
2123
// WARN: The following properties are set dynamically by the runner and are not
2224
// deserialized from the runner config json. They should technically be marked
2325
// as optional, but the runners treat them as required so type them as such.
@@ -72,6 +74,7 @@ export interface CucumberRunnerConfig {
7274
configFile?: string;
7375
version: string;
7476
};
77+
nodeVersion?: string;
7578
suite: CucumberSuite;
7679
assetsDir: string;
7780
sauceReportFile: string;

0 commit comments

Comments
 (0)