Skip to content

Commit

Permalink
Refactor test assertion to be platform agnostic.
Browse files Browse the repository at this point in the history
globby _always_ returns posix style paths (regardless of platform).
In order to search for the "file with the error" in the output, we need
to convert the `path.join` result into posix style paths. We (and
globby) use `slash` for this in other areas, so it is used here for
simplicity and to match the logic globby would use.
  • Loading branch information
rwjblue committed Oct 16, 2019
1 parent ee4680d commit d845e13
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/ember-template-recast-test.js
Expand Up @@ -2,6 +2,7 @@ const execa = require('execa');
const { readFileSync } = require('fs');
const { join } = require('path');
const { createTempDir } = require('broccoli-test-helper');
const slash = require('slash');

function run(args, cwd) {
return execa(require.resolve('../bin/ember-template-recast'), args, { cwd });
Expand Down Expand Up @@ -104,10 +105,13 @@ Errored: 1`
'Status message includes error count'
);

assert.ok(
stdout.includes(join(this.fixture.path(), 'files/bad-template.hbs')),
'Output includes full path to bad template'
);
let badFilePath = slash(join(this.fixture.path(), 'files/bad-template.hbs'));

assert.pushResult({
result: stdout.includes(badFilePath),
message: `Expected output to include full path to the invalid template (${badFilePath}): \n\n${stdout}`,
});

assert.ok(
stdout.includes('Error: Parse error on line 1:'),
'Output includes error stacktrace'
Expand Down

0 comments on commit d845e13

Please sign in to comment.