@spotify/web-scripts
Version:
Build, lint, test, format, and release your JS/TS library.
34 lines (33 loc) • 1.18 kB
JavaScript
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import { default as spawn } from 'cross-spawn';
import { default as Debug } from 'debug';
import { hasConfig } from '@spotify/web-scripts-utils';
import { JEST_CONFIG } from '../Paths';
var dbg = Debug('web-scripts:test');
export function getJestConfig() {
if (!hasConfig([
{ type: 'file', pattern: 'jest.config.js' },
{ type: 'package.json', property: 'jest' },
])) {
return JEST_CONFIG;
}
return null;
}
export function testTask(task) {
var cmd = 'npx';
var config = task.config || getJestConfig();
var args = __spreadArray(__spreadArray([
'--no-install',
'jest'
], (config ? ['--config', config] : []), true), task.restOptions, true);
dbg('npx args %o', args);
return spawn.sync(cmd, args, { stdio: 'inherit' });
}