Browse Source

use relative file paths on the fork.js output

babel-plugin-for-integration-tests
Sindre Sorhus 9 years ago
parent
commit
0a40bdb119
  1. 10
      lib/fork.js
  2. 2
      test/fork.js

10
lib/fork.js

@ -19,6 +19,8 @@ module.exports = function (file, opts) {
var ps = childProcess.fork(filepath, args, options);
var relFile = path.relative('.', file);
var promise = new Promise(function (resolve, reject) {
var testResults;
@ -31,19 +33,19 @@ module.exports = function (file, opts) {
ps.on('exit', function (code) {
if (code > 0 && code !== 143) {
return reject(new Error(file + ' exited with a non-zero exit code: ' + code));
return reject(new Error(relFile + ' exited with a non-zero exit code: ' + code));
}
if (testResults) {
resolve(testResults);
} else {
reject(new Error('Test results were not received from: ' + file));
reject(new Error('Test results were not received from ' + relFile));
}
});
ps.on('no-tests', function (data) {
send(ps, 'teardown');
var message = 'No tests found in ' + path.relative('.', file);
var message = 'No tests found in ' + relFile;
if (!data.avaRequired) {
message += ', make sure to import "ava" at the top of your test file';
}
@ -58,7 +60,7 @@ module.exports = function (file, opts) {
}
event.name = event.name.replace(/^ava\-/, '');
event.data.file = file;
event.data.file = relFile;
debug('ipc %s:\n%o', event.name, event.data);
ps.emit(event.name, event.data);

2
test/fork.js

@ -28,7 +28,7 @@ test('resolves promise with tests info', function (t) {
.then(function (info) {
t.is(info.stats.passCount, 1);
t.is(info.tests.length, 1);
t.is(info.file, file);
t.is(info.file, path.relative('.', file));
t.end();
});
});

Loading…
Cancel
Save