Skip to content

Commit

Permalink
More test refactor & fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Sep 26, 2021
1 parent 25a85b6 commit ff27fce
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 114 deletions.
9 changes: 9 additions & 0 deletions src/test/helpers.ts
Expand Up @@ -12,6 +12,7 @@ import { lock } from 'proper-lockfile';
import type * as tsNodeTypes from '../index';
import type _createRequire from 'create-require';
import { once } from 'lodash';
import semver = require('semver');
const createRequire: typeof _createRequire = require('create-require');
export { tsNodeTypes };

Expand All @@ -25,6 +26,14 @@ export const BIN_SCRIPT_PATH = join(
'node_modules/.bin/ts-node-script'
);
export const BIN_CWD_PATH = join(TEST_DIR, 'node_modules/.bin/ts-node-cwd');
/** Default `ts-node --project` invocation */
export const CMD_TS_NODE_WITH_PROJECT_FLAG = `"${BIN_PATH}" --project "${PROJECT}"`;
/** Default `ts-node` invocation without `--project` */
export const CMD_TS_NODE_WITHOUT_PROJECT_FLAG = `"${BIN_PATH}"`;
export const EXPERIMENTAL_MODULES_FLAG = semver.gte(process.version, '12.17.0')
? ''
: '--experimental-modules';
export const CMD_ESM_LOADER_WITHOUT_PROJECT = `node ${EXPERIMENTAL_MODULES_FLAG} --loader ts-node/esm`;

// `createRequire` does not exist on older node versions
export const testsDirRequire = createRequire(join(TEST_DIR, 'index.js'));
Expand Down

0 comments on commit ff27fce

Please sign in to comment.