Ember Try
Ember Try is an Ember CLI addon designed to facilitate testing Ember applications and addons against various versions of their dependencies, particularly `ember` and `ember-data`. The current stable version is 4.0.0, released in March 2025. It allows developers to define "scenarios" that modify `package.json` dependencies, install them, run a specified command (usually `ember test`), and then revert the changes. This is crucial for maintaining compatibility across different Ember ecosystem versions. Its primary differentiators include deep integration with `ember-cli`, a declarative configuration for scenarios, and commands like `ember try:each` for iterative testing and `ember try:one` for specific scenario runs. It also supports automatic scenario generation based on `semver` ranges in `package.json` via its `versionCompatibility` feature, making it a cornerstone for robust Ember ecosystem testing. The release cadence appears tied to major Ember CLI or Node.js ecosystem shifts, with major versions released periodically to address breaking changes and new features.
Common errors
-
TypeError: Cannot read properties of undefined (reading 'ui')
cause The `project` instance is no longer passed to the `ember-try` config function in v4.0.0, leading to errors if you attempt to access properties of a non-existent `project` argument.fixUpdate `config/ember-try.js` to remove the `project` argument from the exported function signature. For example, change `module.exports = function(project) { ... }` to `module.exports = function() { ... }`. -
Error: Node.js v14.x is no longer supported by ember-try. Please upgrade to Node.js v18.x or higher.
cause Attempting to run `ember-try` v3.0.0 or higher with an unsupported Node.js version (e.g., Node.js 14).fixUpgrade your Node.js environment to version 18 or higher (e.g., using `nvm install 18 && nvm use 18`). -
Bower is not supported for scenarios. Please use npm or pnpm.
cause Your `ember-try` configuration attempts to define scenarios with Bower dependencies after `ember-try` v2.0.0, which removed Bower support.fixMigrate all dependency declarations within your `ember-try` scenarios from Bower to npm or pnpm. `ember-try` exclusively manages Node package manager dependencies. -
My application builds with unexpected dependencies in CI after `ember try:each`.
cause A previous `ember try:one` or `ember try:each` command was run with `--skip-cleanup=true`, and the CI environment was not reset before a build step.fixEnsure `ember try:reset` is explicitly run after any command using `--skip-cleanup=true`, or configure your CI to always perform a clean checkout for build steps to prevent dependency pollution.
Warnings
- breaking The `ember-cli project` instance is no longer passed as an argument to the configuration function exported by `config/ember-try.js`.
- breaking When using pnpm, scripts are ignored by default in scenarios to prevent unintended side effects.
- breaking Node.js 14 support has been dropped.
- breaking Support for scenarios involving Bower dependencies has been dropped.
- gotcha Using the `--skip-cleanup=true` option with `ember try:one` or `ember try:each` can leave your project in a modified state with the last tested dependencies installed.
Install
-
npm install ember-try -
yarn add ember-try -
pnpm add ember-try
Imports
- default export (config function)
// config/ember-try.js import { scenarios } from 'ember-try'; // Incorrect; configuration is a CommonJS module export.// config/ember-try.js module.exports = function(/* app */) { return { scenarios: [ { name: 'ember-lts-4.4', npm: { devDependencies: { 'ember-source': '~4.4.0' } } }, { name: 'ember-beta', npm: { devDependencies: { 'ember-source': 'beta' } } } ] }; }; - versionCompatibility (package.json)
// package.json { "ember-addon": { "versionCompatibility": "^3.28.0" // Not a valid object structure for defining compatibility } }// package.json { "ember-addon": { "versionCompatibility": { "ember": ">=3.28.0 <5.0.0" } } } - CLI Commands
ember try:each ember try:one ember-beta --- ember test ember try:reset
Quickstart
// First, install ember-try in your Ember CLI project:
ember install ember-try
// This will typically create or update 'config/ember-try.js'.
// Modify 'config/ember-try.js' to define your testing scenarios:
module.exports = function(/* app */) {
return {
useVersionCompatibility: true, // Auto-generate scenarios from package.json if desired
scenarios: [
{
name: 'ember-default',
npm: {
devDependencies: {} // Uses dependencies defined in your project's package.json
}
},
{
name: 'ember-release',
npm: {
devDependencies: {
'ember-source': 'release' // Test against the latest stable Ember release
}
}
},
{
name: 'ember-beta',
npm: {
devDependencies: {
'ember-source': 'beta' // Test against the Ember beta channel
}
},
allowedToFail: true // Beta/Canary scenarios can be configured to fail without blocking CI
},
{
name: 'ember-canary',
npm: {
devDependencies: {
'ember-source': 'canary' // Test against the Ember canary channel
}
},
allowedToFail: true
}
]
};
};
// Then, run the `ember try:each` command to execute tests for all scenarios:
ember try:each