Ember CLI Internal Test Helpers
raw JSON → 0.9.1 verified Sat Apr 25 auth: no javascript maintenance
This package, `ember-cli-internal-test-helpers`, provides a collection of utility functions designed exclusively for internal testing within the `ember-cli` project itself. It is not intended for use in Ember applications or addons developed by end-users. The current stable version is `0.9.1`. As an internal utility, it does not follow a public release cadence and its API may change without warning, reflecting the needs of the `ember-cli` core development. Its key differentiator is its specialized focus on testing `ember-cli`'s own architecture, such as blueprint generation and command execution, rather than providing helpers for testing Ember application components or routes.
Common errors
error Error: Cannot find module 'ember-cli-internal-test-helpers/lib/helpers/some-unknown-helper' ↓
cause Attempting to import a helper that does not exist at the specified path or trying to use ES Modules `import` syntax.
fix
Verify the exact path and name of the helper in the package's
lib/helpers directory on GitHub. Ensure you are using CommonJS require() syntax for Node.js environments. error TypeError: someHelper is not a function ↓
cause The imported symbol is not a function, or the helper was not correctly destructuring from `module.exports`.
fix
Ensure you are correctly destructuring the named export (e.g.,
const { stub } = require(...)) or accessing the property on the imported module (e.g., const helpers = require(...); helpers.stub(...)). Check the source code for the correct export structure. Warnings
gotcha This package is explicitly for internal `ember-cli` development and is NOT intended for use in Ember applications or addons. Its API is unstable and subject to change without notice. ↓
fix Do not install or use `ember-cli-internal-test-helpers` in your application or addon. Use `@ember/test-helpers` or other community-maintained test helper addons instead.
breaking Version 0.8.0 removed `ember-cli` as a `devDependency`. This means the package now implicitly relies on `ember-cli` being present in the environment where it runs, rather than explicitly declaring it as a dependency. While internal, developers consuming it directly might see `ember-cli` missing errors. ↓
fix Ensure `ember-cli` is available in your test environment's `node_modules` if you are maintaining or extending `ember-cli`'s internal tests that use this package. For end-users, this change reinforces that the package is not for general consumption.
gotcha The helpers are Node.js-based and exported via CommonJS `module.exports`. They are not exposed to the browser testing environment through `app.import`s or global registrations, unlike typical Ember test helpers. ↓
fix Do not attempt to `import` these helpers for use in browser-based Ember application tests (e.g., integration or acceptance tests). They are designed for Node.js-specific testing contexts within `ember-cli`.
Install
npm install ember-cli-internal-test-helpers yarn add ember-cli-internal-test-helpers pnpm add ember-cli-internal-test-helpers Imports
- stub wrong
import { stub } from 'ember-cli-internal-test-helpers/lib/helpers/stub'; // or import stub from 'ember-cli-internal-test-helpers/lib/helpers/stub';correctconst { stub } = require('ember-cli-internal-test-helpers/lib/helpers/stub'); - module.exports
const addon = require('ember-cli-internal-test-helpers');
Quickstart
const { stub } = require('ember-cli-internal-test-helpers/lib/helpers/stub');
const assert = require('assert');
function myFunction(obj) {
return obj.someMethod();
}
// Example of using an internal stub helper in a conceptual Node.js test
describe('Internal Ember CLI Test Logic', function() {
let originalMethod;
let testObject = {
someMethod: () => 'original value'
};
beforeEach(() => {
// Stubs are typically managed within test setup/teardown
originalMethod = testObject.someMethod;
stub(testObject, 'someMethod', () => 'stubbed value');
});
afterEach(() => {
testObject.someMethod = originalMethod;
});
it('should use the stubbed method', function() {
assert.strictEqual(myFunction(testObject), 'stubbed value');
});
});