Skip to content

Commit

Permalink
chore: Re-enable running karma tests for a single test file (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradJChan authored and mergify[bot] committed Aug 30, 2019
1 parent 5bb3491 commit d2deb4d
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions build/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ const MODEL3D_STATIC_ASSETS_VERSION = '1.12.0';
const SWF_STATIC_ASSETS_VERSION = '0.112.0';
const TEXT_STATIC_ASSETS_VERSION = '0.114.0';

const getTestFile = (src) => {
if (!src) {
return [
'src/lib/**/*-test.js',
'src/lib/**/*-test.html'
];
}

if (src.endsWith('/')) {
return [
`src/lib/${src}**/*-test.js`,
`src/lib/${src}**/*-test.html`
];
}

const frags = src.split('/');
const fileName = frags[frags.length - 1];
if (!fileName) {
throw new Error('Incorrect path to source file');
}

const path = src.replace(fileName, '');
const base = path ? `src/lib/${path}` : 'src/lib';
return [
`${base}/__tests__/${fileName}-test.js`,
`${base}/__tests__/${fileName}-test.html`
];
};

module.exports = config =>
config.set({
autoWatch: false,
Expand Down Expand Up @@ -68,9 +97,7 @@ module.exports = config =>
`src/third-party/model3d/${MODEL3D_STATIC_ASSETS_VERSION}/**/*.js`,
`src/third-party/swf/${SWF_STATIC_ASSETS_VERSION}/**/*.js`,
`src/third-party/text/${TEXT_STATIC_ASSETS_VERSION}/**/*.js`,
'src/**/__tests__/**/*-test.js',
'src/**/__tests__/**/*-test.html',
],
].concat(getTestFile(config.src)),

preprocessors: {
'src/**/__tests__/**/*-test.js': ['webpack', 'sourcemap'],
Expand Down

0 comments on commit d2deb4d

Please sign in to comment.