Skip to content

Commit

Permalink
added integration test for bugfix when tests and source are in same dir
Browse files Browse the repository at this point in the history
  • Loading branch information
ldgit committed May 19, 2020
1 parent e0c12f2 commit 42cee00
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/integration/argus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,54 @@ describe('argus', function argusTestSuite() {
});
});
});

context('tests-and-source-together', () => {
let runCommandsSpy;

beforeEach(() => {
process.chdir(path.join('.', 'test', 'integration', 'fixtures', 'tests-and-source-together'));
runCommandsSpy = createRunCommandsSpy();
runArgus = configureRunArgus(runCommandsSpy, commandLineOptions, mockStdin);
});

it('should watch project with test and source next to each other', async () => {
watcher = runArgus();
fork(pathToTouchScript, [path.join('.', 'src', 'app.js')]);

const { commandCount, firstCommand } = await new Promise(resolve => {
watcher.on('change', () => {
waitForDebounce().then(() => {
resolve({
commandCount: runCommandsSpy.getLastRunCommands().length,
firstCommand: runCommandsSpy.getLastRunCommands()[0],
});
});
});
});

expect(commandCount).to.equal(1, 'Expected one command to run');
expect(firstCommand.command).to.equal('echo "I test thee"');
expect(firstCommand.args).to.eql(['src/app.test.js'].map(filepath => path.join(filepath)));
});

it('should watch project with test and source next to each other (test file changed)', async () => {
watcher = runArgus();
fork(pathToTouchScript, [path.join('.', 'src', 'app.test.js')]);

const { commandCount, firstCommand } = await new Promise(resolve => {
watcher.on('change', () => {
waitForDebounce().then(() => {
resolve({
commandCount: runCommandsSpy.getLastRunCommands().length,
firstCommand: runCommandsSpy.getLastRunCommands()[0],
});
});
});
});

expect(commandCount).to.equal(1, 'Expected one command to run');
expect(firstCommand.command).to.equal('echo "I test thee"');
expect(firstCommand.args).to.eql(['src/app.test.js'].map(filepath => path.join(filepath)));
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
environments: [
{
extension: 'js',
testNameSuffix: '.test',
testDir: 'src',
sourceDir: 'src',
testRunnerCommand: { command: 'echo "I test thee"' },
},
],
};
Empty file.
Empty file.

0 comments on commit 42cee00

Please sign in to comment.