ember-try provides five main ember-cli commands for testing against multiple dependency scenarios.
Runs the specified command (default: ember test) with each scenario defined in the configuration. This is the primary command for CI environments to test against multiple ember versions.
// Command properties
{
name: 'try:each',
description: 'Runs each of the dependency scenarios specified in config with the specified command. The command defaults to `ember test`',
works: 'insideProject',
availableOptions: [
{ name: 'skip-cleanup', type: Boolean, default: false },
{ name: 'config-path', type: String }
]
}
// Command execution
async function run(commandOptions: {
skipCleanup?: boolean;
configPath?: string;
}): Promise<number>;Usage Examples:
# Run all scenarios
ember try:each
# Skip cleanup (useful in CI)
ember try:each --skip-cleanup=true
# Use custom config file
ember try:each --config-path="config/legacy-scenarios.js"The EMBER_TRY_CURRENT_SCENARIO environment variable is set during execution to the name of the current scenario being tested.
Runs any ember command with a specific scenario. Command defaults to ember test if not specified after the --- separator.
// Command properties
{
name: 'try:one',
description: 'Run any `ember` command with the specified dependency scenario. This optional command is preceded by " --- " and will default to `ember test`',
works: 'insideProject',
anonymousOptions: ['<scenario>'],
availableOptions: [
{ name: 'skip-cleanup', type: Boolean, default: false },
{ name: 'config-path', type: String }
]
}
// Command execution
async function run(
commandOptions: {
skipCleanup?: boolean;
configPath?: string;
},
rawArgs: string[]
): Promise<number>;
// Helper method to extract command from arguments
function getCommand(_argv?: string[]): string[];Usage Examples:
# Run specific scenario with default test command
ember try:one ember-lts-3.16
# Run specific scenario with custom command
ember try:one ember-beta --- ember test --reporter xunit
# Run scenario with serve command
ember try:one ember-canary --- ember serve
# Use custom config and skip cleanup
ember try:one ember-beta --config-path="config/legacy-scenarios.js" --skip-cleanup=trueRuns tests with each Ember version that matches the provided semver statement. Uses automatic scenario generation based on the semver range.
// Command properties
{
name: 'try:ember',
description: 'Runs with each Ember version matching the semver statement given. The command defaults to `ember test`',
works: 'insideProject',
anonymousOptions: ['<ember-semver-statement>'],
availableOptions: [
{ name: 'skip-cleanup', type: Boolean, default: false },
{ name: 'config-path', type: String }
]
}
// Command execution
async function run(
commandOptions: {
skipCleanup?: boolean;
configPath?: string;
},
rawArgs: string[]
): Promise<number>;Usage Examples:
# Test against ember versions in range
ember try:ember ">=3.16.0 <4.0.0"
# Test against specific version
ember try:ember "3.20.0"
# Test with custom config
ember try:ember ">2.18.0 < 4.0.0" --config-path="config/ember-versions.js"Displays the configuration that will be used by ember-try, including resolved scenarios.
// Command properties
{
name: 'try:config',
description: 'Displays the config that will be used',
works: 'insideProject',
availableOptions: [
{ name: 'config-path', type: String }
]
}
// Command execution
async function run(commandOptions: {
configPath?: string;
}): Promise<void>;Usage Examples:
# Display current configuration
ember try:config
# Display configuration from custom path
ember try:config --config-path="config/legacy-scenarios.js"Resets dependencies to their committed state. Useful when things get messy or after running with --skip-cleanup.
// Command properties
{
name: 'try:reset',
description: 'Resets dependencies to their committed state. For when things get messy.',
works: 'insideProject'
}
// Command execution
async function run(): Promise<void>;Usage Examples:
# Reset dependencies to original state
ember try:resetAll commands except try:reset support these options:
Set during scenario execution to the name of the current scenario being tested. This allows test customization based on the active scenario.
// In your test code
if (process.env.EMBER_TRY_CURRENT_SCENARIO === 'ember-canary') {
// Skip unstable tests for canary builds
return;
}Commands return appropriate exit codes:
allowedToFail)allowedToFail