Skip to content

Commit

Permalink
Allow absolute paths as entries
Browse files Browse the repository at this point in the history
fixes #115
workaround until #145 is ready to merge
  • Loading branch information
zinserjan committed Jul 17, 2017
1 parent 6b834a1 commit f6a9cfd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/runner/TestRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import _ from 'lodash';
import chokidar from 'chokidar';

import { glob } from '../util/glob';
import { ensureAbsolutePath } from '../util/paths';
import createCompiler from '../webpack/compiler/createCompiler';
import createWatchCompiler from '../webpack/compiler/createWatchCompiler';
import registerInMemoryCompiler from '../webpack/compiler/registerInMemoryCompiler';
Expand Down Expand Up @@ -244,7 +245,7 @@ export default class TestRunner extends EventEmitter {

const entryConfig = new EntryConfig();
files
.map((f) => path.join(this.options.cwd, f))
.map((f) => ensureAbsolutePath(f, this.options.cwd))
.forEach((f) => entryConfig.addFile(f));

const includeLoaderQuery = {
Expand Down
8 changes: 8 additions & 0 deletions src/util/paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @flow
import { join, posix, win32 } from 'path';

// eslint-disable-next-line import/prefer-default-export
export function ensureAbsolutePath(path: string, basePath: string) {
return posix.isAbsolute(path) || win32.isAbsolute(path) ? path : join(basePath, path);
}

20 changes: 20 additions & 0 deletions test/integration/cli/entry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,26 @@ describe('cli - entry', function () {
});
});

context('entry with absolute paths', function () {
before(function () {
this.passingTest = path.join(process.cwd(), fixtureDirTmp, 'passing-test.js');
createTest(this.passingTest, true);
});

it('runs test with absolute entry', function (done) {
exec(`node ${binPath} "${this.passingTest}"`, (err, stdout) => {
assert.isNull(err);
assert.include(stdout, this.passingTest);
assert.include(stdout, '1 passing');
done();
});
});

after(function () {
return del([this.passingTest]);
});
});

context('glob pattern as option', function () {
const testFiles = _.range(1, 30).map((x) => {
if (parseInt(x / 10, 10) === 0) {
Expand Down

0 comments on commit f6a9cfd

Please sign in to comment.