Skip to content

Commit

Permalink
Merge pull request #8387 from ppcano/fix-mu-addon-tests
Browse files Browse the repository at this point in the history
Fix non-acceptance tests for MU addons
  • Loading branch information
rwjblue committed Jan 27, 2019
2 parents 31ed510 + b6981cd commit 5b1cfe6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/broccoli/default-packager.js
Expand Up @@ -850,13 +850,28 @@ module.exports = class DefaultPackager {
});

if (this.isModuleUnificationEnabled) {
let testSrcTree = new Funnel(tree, {
srcDir: 'src',

let destDir,
testSrcTree,
srcDir;

// ember-addon
if (this.name === 'dummy') {
testSrcTree = 'src';
destDir = `${this.project.name()}/src`;
} else {
testSrcTree = tree;
destDir = `${this.name}/src`;
srcDir = 'src';
}
testSrcTree = new Funnel(testSrcTree, {
srcDir,
include: ['**/*-test.{js,ts}'],
annotation: 'Module Unification Tests',
});

testSrcTree = new Funnel(testSrcTree, {
destDir: `${this.name}/src`,
destDir,
});

treeToCompile = mergeTrees([treeToCompile, testSrcTree], {
Expand Down Expand Up @@ -1079,7 +1094,7 @@ module.exports = class DefaultPackager {
});

return concat(appTestTrees, {
inputFiles: [`${this.name}/{tests,src}/**/*.js`],
inputFiles: ['**/{tests,src}/**/*.js'],
headerFiles: ['vendor/ember-cli/tests-prefix.js'],
footerFiles: ['vendor/ember-cli/app-config.js', 'vendor/ember-cli/tests-suffix.js'],
outputFile: this.distPaths.testJsFile,
Expand Down
30 changes: 30 additions & 0 deletions tests/acceptance/addon-smoke-test-slow.js
Expand Up @@ -140,6 +140,36 @@ describe('Acceptance: addon-smoke-test', function() {
expect(outputFiles).to.not.contain(unnecessaryFiles);
expect(outputFiles).to.not.contain(unnecessaryFolders);
}));

if (isExperimentEnabled('MODULE_UNIFICATION')) {

it('can run a MU unit test with a relative import', co.wrap(function *() {
yield copyFixtureFiles('brocfile-tests/mu-unit-test-with-relative-import');

let packageJsonPath = path.join(addonRoot, 'package.json');
let packageJson = fs.readJsonSync(packageJsonPath);

packageJson.dependencies = packageJson.dependencies || {};
// add HTMLBars for templates (generators do this automatically when components/templates are added)
packageJson.dependencies['ember-cli-htmlbars'] = 'latest';

fs.writeJsonSync(packageJsonPath, packageJson);

let result = yield runCommand('node_modules/ember-cli/bin/ember', 'build');
expect(result.code).to.eql(0);

let appFileContents = fs.readFileSync(path.join(addonRoot, 'dist', 'assets', 'tests.js'), {
encoding: 'utf8',
});

expect(appFileContents).to.include('Unit | Utility | string');

result = yield runCommand('node_modules/ember-cli/bin/ember', 'test');
expect(result.code).to.eql(0);

}));

}
});

function npmPack() {
Expand Down

0 comments on commit 5b1cfe6

Please sign in to comment.