Skip to content

Commit

Permalink
feat: enable use of global node context
Browse files Browse the repository at this point in the history
  • Loading branch information
alexplischke committed Aug 1, 2024
1 parent 9a484e8 commit 3afcf11
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/cucumber-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { prepareNpmEnv, preExec } from 'sauce-testrunner-utils';

import type { CucumberRunnerConfig } from './types';
import * as utils from './utils';
import { NodeContext } from 'sauce-testrunner-utils/lib/types';

function buildArgs(runCfg: CucumberRunnerConfig, cucumberBin: string) {
const paths: string[] = [];
Expand Down Expand Up @@ -88,7 +89,11 @@ export async function runCucumber(
'bin',
'npm-cli.js',
);
const nodeCtx = { nodePath: nodeBin, npmPath: npmBin };
const nodeCtx: NodeContext = {
nodePath: nodeBin,
npmPath: npmBin,
useGlobals: !!runCfg.nodeVersion,
};

// Install NPM dependencies
await prepareNpmEnv(runCfg, nodeCtx);
Expand Down
7 changes: 6 additions & 1 deletion src/playwright-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as convert from 'xml-js';
import { runCucumber } from './cucumber-runner';
import type { CucumberRunnerConfig, RunnerConfig } from './types';
import * as utils from './utils';
import { NodeContext } from 'sauce-testrunner-utils/lib/types';

function getPlatformName(platformName: string) {
if (process.platform.toLowerCase() === 'linux') {
Expand Down Expand Up @@ -359,7 +360,11 @@ async function runPlaywright(
'bin',
'npm-cli.js',
);
const nodeCtx = { nodePath: nodeBin, npmPath: npmBin };
const nodeCtx: NodeContext = {
nodePath: nodeBin,
npmPath: npmBin,
useGlobals: !!runCfg.nodeVersion,
};

// runCfg.path must be set for prepareNpmEnv to find node_modules. :(
await prepareNpmEnv(runCfg, nodeCtx);
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface RunnerConfig {
version: string;
};

nodeVersion?: string;

// WARN: The following properties are set dynamically by the runner and are not
// deserialized from the runner config json. They should technically be marked
// as optional, but the runners treat them as required so type them as such.
Expand Down Expand Up @@ -72,6 +74,7 @@ export interface CucumberRunnerConfig {
configFile?: string;
version: string;
};
nodeVersion?: string;
suite: CucumberSuite;
assetsDir: string;
sauceReportFile: string;
Expand Down

0 comments on commit 3afcf11

Please sign in to comment.