Registry /
testing / ember-cli-blueprint-test-helpers
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
setupTestHooks
✓ import { setupTestHooks } from 'ember-cli-blueprint-test-helpers';
✗ const setupTestHooks = require('ember-cli-blueprint-test-helpers').setupTestHooks;
The `setupTestHooks` function prepares the test context and typically makes other helpers like `emberNew`, `emberGenerate`, `emberDestroy`, and `file` globally available or bound to the Mocha `this` context.
emberGenerate
✓ import { emberGenerate } from 'ember-cli-blueprint-test-helpers';
✗ emberGenerate(); // without explicit import after setupTestHooks(this);
While often available globally after calling `setupTestHooks(this)`, explicit named imports are the recommended practice for clarity in modern JavaScript and TypeScript environments.
emberGenerateDestroy
✓ import { emberGenerateDestroy } from 'ember-cli-blueprint-test-helpers';
✗ const { emberGenerateDestroy } = require('ember-cli-blueprint-test-helpers/helpers');
This helper is available as a named export. While `require('ember-cli-blueprint-test-helpers/helpers')` explicitly exports helpers, the main package export often re-exports these directly.
file
✓ import { file } from 'ember-cli-blueprint-test-helpers';
✗ expect(file('path/to/file.js')); // No import statement
The `file` helper is used to make assertions on the contents and existence of files in the temporary blueprint test environment. It is often implicitly available after `setupTestHooks` but should be explicitly imported for type safety and clarity.
This quickstart demonstrates how to set up blueprint tests using Mocha and Chai, generate and destroy a hypothetical 'my-blueprint', and assert file existence and content. It also shows testing with Module Unification.
import { setupTestHooks, emberNew, emberGenerate, emberDestroy, file } from 'ember-cli-blueprint-test-helpers';
import { expect } from 'chai';
describe('Acceptance: ember generate and destroy my-blueprint', function() {
// Create and destroy temporary working directories for each test
setupTestHooks(this);
it('my-blueprint foo generates and cleans up files', async function() {
const args = ['my-blueprint', 'foo'];
// Create a new Ember.js app in the working directory
await emberNew();
// Generate the `my-blueprint` blueprint with name `foo`
await emberGenerate(args);
// Assert that the files were generated correctly
expect(file('app/components/foo.js')).to.exist;
expect(file('app/components/foo.js'))
.to.contain('import Component from '@glimmer/component';')
.to.contain('export default class FooComponent extends Component {}');
// Destroy the `my-blueprint` blueprint with name `foo`
await emberDestroy(args);
// Assert that the generated files were destroyed correctly
expect(file('app/components/foo.js')).to.not.exist;
});
it('my-blueprint bar with Module Unification', async function() {
const args = ['my-blueprint', 'bar'];
// Create a new Ember.js app with Module Unification structure
await emberNew({ isModuleUnification: true });
// Generate and destroy the `my-blueprint` blueprint called `bar`
await emberGenerateDestroy(args, (fileContents) => {
// Assertions run between generate and destroy
expect(fileContents('src/ui/components/bar/component.js')).to.exist;
expect(fileContents('src/ui/components/bar/component.js'))
.to.contain('// Module Unification component content');
});
});
});
Errors
Common errors & fixes
TypeError: (0 , _emberCliBlueprintTestHelpers.setupTestHooks) is not a function
This error typically occurs when `setupTestHooks` is imported or required incorrectly, or when attempting to destructure it from a module that doesn't export it in the expected way.
fixEnsure you are using the correct CommonJS `require` or ES module `import` syntax for the helper functions. For CommonJS: `const { setupTestHooks } = require('ember-cli-blueprint-test-helpers');` or for ESM: `import { setupTestHooks } from 'ember-cli-blueprint-test-helpers';`. AssertionError: expected 'path/to/file.js' to contents 'some content'
This error indicates that an outdated assertion helper `contents` is being used, which was renamed in a previous version of the library.
fixReplace `contents` with `contain`. The correct assertion syntax is `expect(file('path/to/file.js')).to.contain('some content');`. Error: Blueprint tests for apps are not supported. Only addons.
Attempting to run blueprint tests using this library within an Ember application project rather than an Ember addon project, which is an unsupported use case.
fixRelocate your blueprint tests to an Ember addon project. This library is specifically designed to test blueprints contained within addons.
Audit
Dependencies
rsvprequiredInternal dependency added in v0.12.1, likely for promise-based operations within the helpers.
globrequiredInternal dependency added in v0.10.0, likely for file system operations like finding blueprint files.
chairequiredCommonly used assertion library in conjunction with this package for blueprint tests, often exposed via `require('ember-cli-blueprint-test-helpers/chai')`.
mocharequiredTypically used as the test runner for `node-tests` where blueprint tests are executed. Configured in `package.json` scripts.