• Stars
    star
    179
  • Rank 214,039 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An ember-cli addon to test against multiple npm dependencies, such as ember and ember-data.

ember-try

npm version GitHub Actions Build Status Ember Observer Score Build status Code Climate Test Coverage

An ember-cli addon to test against multiple dependencies, such as ember and ember-data.

Installation

ember install ember-try

Usage

This addon provides a few commands:

ember try:each

This command will run ember test or the configured command with each scenario's specified in the config and exit appropriately.

This command is especially useful to use on CI to test against multiple ember versions.

In order to use an alternate config path or to group various scenarios together in a single try:each run, you can use the --config-path option.

  ember try:each --config-path="config/legacy-scenarios.js"

If you need to know the scenario that is being run (i.e. to customize a test output file name) you can use the EMBER_TRY_CURRENT_SCENARIO environment variable.

ember try:one <scenario> (...options) --- <command (Default: ember test)>

This command will run any ember-cli command with the specified scenario. The command will default to ember test, if no command is specified on the command-line or in configuration.

For example:

  ember try:one ember-1.11-with-ember-data-beta-16 --- ember test --reporter xunit

or

  ember try:one ember-1.11-with-ember-data-beta-16 --- ember serve

When running in a CI environment where changes are discarded you can skip resetting your environment back to its original state by specifying --skip-cleanup=true as an option to ember try. Warning: If you use this option and, without cleaning up, build and deploy as the result of a passing test suite, it will build with the last set of dependencies ember try was run with.

  ember try:one ember-1.11 --skip-cleanup=true --- ember test

In order to use an alternate config path or to group various scenarios, you can use the --config-path option.

  ember try:one ember-1.13 --config-path="config/legacy-scenarios.js"

ember try:reset

This command restores the original package.json from package.json.ember-try, rm -rfs node_modules and runs npm install. For use if any of the other commands fail to clean up after (they run this by default on completion).

ember try:ember <semver-string>

Runs ember test or the command in config for each version of Ember that is possible under the semver string given. Configuration follows the rules given under the versionCompatibility heading below.

ember try:config

Displays the configuration that will be used. Also takes an optional --config-path.

Config

versionCompatibility

If you're using ember-try with an Ember addon, there is a short cut to test many Ember versions. In your package.json under the ember-addon key, add the following:

  "ember-addon": {
    "versionCompatibility": {
       "ember": ">2.18.0 < 4.0.0"
    }
  }

The value for "ember" can be any valid semver statement. This will autogenerate scenarios for each version of Ember that matches the statement. It will also include scenarios for beta and canary channels of Ember that will be allowed to fail. These scenarios will ONLY be used if scenarios is NOT a key in the configuration file being used. If useVersionCompatibility is set to true in the config file, the autogenerated scenarios will deep merge with any scenarios in the config file. For example, you could override just the allowedToFail property of the ember-beta scenario.

To keep this from getting out of hand, ember-try will limit the versions of Ember used to the lasted point release per minor version. For example, ">1.11.0 <=2.0.0", would (as of writing) run with versions ['1.11.4', '1.12.2', '1.13.13', '2.0.0'].

Configuration Files

Configuration will be read from a file in your ember app in config/ember-try.js. Here are the possible options:

const getChannelURL = require('ember-source-channel-url');

module.exports = async function() {
  return {
    /*
      `command` - a single command that, if set, will be the default command used by `ember-try`.
      P.S. The command doesn't need to be an `ember <something>` command, they can be anything.
      Keep in mind that this config file is JavaScript, so you can code in here to determine the command.
    */
    command: 'ember test --reporter xunit',
    /*
      `npmOptions` - options to be passed to `npm`.
    */
    npmOptions: ['--loglevel=silent', '--no-shrinkwrap=true'],
    /*
      If set to true, the `versionCompatibility` key under `ember-addon` in `package.json` will be used to
      automatically generate scenarios that will deep merge with any in this configuration file.
    */
    useVersionCompatibility: true,
    /*
      If set to true, all npm scenarios will use `yarn` for install with the `--no-lockfile` option. At cleanup, your
      dependencies will be restored to their prior state.
    */
    useYarn: true,

    /*
      buildManagerOptions allows you to opt-out of the default options such as `--ignore-engines --no-lockfile`.
      The buildManagerOptions function is aware of each scenario so you can customize your options.
    */
    buildManagerOptions(scenario) {
      return ['--ignore-engines'];
    }

    scenarios: [
      {
        name: 'Ember 2.11.0',
        /*
          `env` can be set per scenario, with environment variables to set for the command being run.
          This will be merged with process.env
       */
        env: {
          ENABLE_NEW_DASHBOARD: true
        },
        npm: {
          devDependencies: {
            'ember-source': '2.11.0'
          },
          /*
            You can optionally define npm overrides to enforce a  specific dependency version
            to be installed. This is useful if other libraries you depend on include different
            versions of a package. This does nothing if `useYarn` is true;
          */
          overrides: {
            'lodash': '5.0.0'
          }
          /*
            When `useYarn` is true, you can optionally define yarn resolutions to enforce a
            specific dependency version to be installed. This is useful if other libraries
            you depend on include different versions of a package.
          */
          resolutions: {
            'lodash': '5.0.0'
          }
          /*
            In order to easily test multiple editions ember-try merges any `ember` property specified
            into the applications `package.json`. Values specified in the ember-try configuration will
            override values that pre-existed in the original `package.json`.
          */
          ember: {
            'edition': 'octane'
          }
        }
      },
      {
        name: 'Ember canary with Ember-Data 2.3.0',
        /*
          `allowedToFail` - If true, if this scenario fails it will not fail the entire try command.
        */
        allowedToFail: true,
        npm: {
          devDependencies: {
            'ember-data': '2.3.0',

            'ember-source': await getChannelURL('canary')

            // you can remove any package by marking `null`
            'some-optional-package': null
          }
        },
      },
      {
        name: 'ember-beta',
        npm: {
          devDependencies: {
            'ember-source': await getChannelURL('beta')
          }
        }
      },
    ]
  };
};

Scenarios are sets of dependencies. They can be specified exactly as in the package.json The name can be used to try just one scenario using the ember try:one command.

Yarn

If you include useYarn: true in your ember-try config, all npm scenarios will use yarn for install with the --no-lockfile option. At cleanup, your dependencies will be restored to their prior state.

A note on npm scenarios with lockfiles

Lockfiles are ignored by ember-try. (yarn will run with --no-lockfile and npm will be run with --no-shrinkwrap). When testing various scenarios, it's important to "float" dependencies so that the scenarios are run with the latest satisfying versions of dependencies a user of the project would get.

Workspaces

If you include useWorkspaces: true in your ember-try config, ember-try will apply the diff to each individual workspace specified in package.json, allowing you to try scenarios in monorepo style repositories. See Yarn's documentation of workspaces for more details.

Video

How to use EmberTry

See an example of using ember-try for CI here, and the resulting build output.

Special Thanks

  • Much credit is due to Edward Faulkner The scripts in liquid-fire that test against multiple ember versions were the inspiration for this project.

Developing

  • Be sure to run npm link and npm link ember-try, otherwise any ember try commands you run will use the version of ember-try included by ember-cli itself.

More Repositories

1

ember-cli

The Ember.js command line utility.
JavaScript
3,261
star
2

ember-exam

Run your tests with randomization, splitting, and parallelization for beautiful tests.
JavaScript
286
star
3

ember-cli-update

Update Ember CLI projects
JavaScript
277
star
4

ember-twiddle

JSFiddle type thing for ember-cli style code
JavaScript
268
star
5

eslint-plugin-ember

An ESLint plugin that provides set of rules for Ember applications based on commonly known good practices.
JavaScript
260
star
6

ember-ajax

Service for making AJAX requests in Ember applications
JavaScript
213
star
7

ember-page-title

Page title management for Ember.js Apps
JavaScript
188
star
8

ember-fetch

HTML5 fetch polyfill from github wrapped and bundled for ember-cli users.
JavaScript
176
star
9

ember-cli-deprecation-workflow

JavaScript
165
star
10

ember-cli-mocha

Mocha and Chai tests for ember-cli applications
JavaScript
147
star
11

ember-cli-eslint

Ember CLI addon for linting Ember projects with ESLint
JavaScript
116
star
12

ember-new-output

Change history of new Ember-CLI apps
JavaScript
91
star
13

ember-resolver

JavaScript
87
star
14

broccoli-asset-rev

Broccoli plugin to add fingerprint checksums and CDN URLs to your assets
JavaScript
86
star
15

ember-rfc176-data

JSON data for Ember.js RFC #176
JavaScript
83
star
16

loader.js

minimal amd loader mostly stolen from wycats.
JavaScript
79
star
17

ember-cli-htmlbars

JavaScript
77
star
18

ember-template-imports

Template import support in Ember!
JavaScript
74
star
19

ember-cli-htmlbars-inline-precompile

πŸ“ƒ Precompile inline HTMLBars templates via ES6 tagged template strings
JavaScript
67
star
20

ember-cli-todos

JavaScript
67
star
21

babel-plugin-feature-flags

A babel transform for managing feature flags
JavaScript
57
star
22

ember-cli-app-version

Adds your app's version to Ember Inspector's Info tab
JavaScript
55
star
23

ember-cli-shims

DEPRECATED - ES6 import shims for Ember.js
JavaScript
46
star
24

ember-octane-blueprint

App and Addon blueprints for Ember Octane
JavaScript
46
star
25

rfcs

Archive of RFCs for changes to ember-cli (for current RFC repo see https://github.com/emberjs/rfcs)
45
star
26

ember-cli-babel-polyfills

Split-build polyfills for evergreen and legacy browsers
JavaScript
34
star
27

ember-cli-qunit

QUnit testing package for ember-cli applications
JavaScript
30
star
28

ember-compatibility-helpers

Helpers that allow you to write backwards compat Ember addons
JavaScript
24
star
29

ember-cli-version-checker

Dependency version checker for Ember CLI addons
JavaScript
24
star
30

broccoli-viz

library to read/parse and produce various visualizations of broccoli.
JavaScript
23
star
31

ember-cli-blueprint-test-helpers

Test helpers for testing ember-cli blueprints
JavaScript
23
star
32

ember-cli-terser

JavaScript minification for Ember-CLI
JavaScript
23
star
33

ember-cli-inject-live-reload

Ember CLI plugin that injects live-reload script into HTML content
JavaScript
22
star
34

ember-cli-chai

Chai assertions for Ember.js
JavaScript
21
star
35

babel-plugin-filter-imports

A babel transform for filtering out imports
JavaScript
18
star
36

broccoli-caching-writer

JavaScript
17
star
37

ember-addon-output

Change history of new Ember-CLI addons
JavaScript
16
star
38

core-object

JavaScript
16
star
39

babel-plugin-ember-modules-api-polyfill

Polyfill for Ember JS API
JavaScript
15
star
40

ember-load-initializers

JavaScript
14
star
41

console-ui

JavaScript
14
star
42

broccoli-es6modules

new es6 module transpiler
JavaScript
14
star
43

ember-export-application-global

JavaScript
14
star
44

babel-plugin-debug-macros

TypeScript
13
star
45

ember-cli.github.io

Our documentation site
SCSS
13
star
46

ember-router-generator

JavaScript
12
star
47

ember-welcome-page

Welcome page for Ember CLI applications
JavaScript
12
star
48

broccoli-terser-sourcemap

Broccoli filter to uglify with sourcemaps
JavaScript
10
star
49

broccoli-asset-rewrite

Broccoli plugin to rewrite a source tree from an asset map.
JavaScript
10
star
50

ember-cli-test-loader

JavaScript
10
star
51

ember-source-channel-url

JavaScript
10
star
52

stress-app

HTML
9
star
53

capture-exit

JavaScript
9
star
54

ember-next

A home for experiments that aim to become the defaults when running ember-new.
JavaScript
9
star
55

babel-plugin-htmlbars-inline-precompile

Babel plugin to replace tagged template strings with precompiled HTMLBars templates
JavaScript
9
star
56

broccoli-lint-eslint

Integrates JavaScript linting with ESLint as part of your Broccoli build pipeline.
JavaScript
8
star
57

blprnt

JavaScript
7
star
58

ember-cli-clean-css

CSS minification via clean-css for Ember CLI
JavaScript
6
star
59

exists-sync

Deprecated, please use fs.existsSync instead
JavaScript
6
star
60

ember-disable-prototype-extensions

Disables Ember's prototype extensions
JavaScript
6
star
61

silent-error

JavaScript
5
star
62

ember-cli-jshint

JSHint lint tests for your Ember CLI projects
JavaScript
5
star
63

create-ember-app

yarn create ember-app <name>
JavaScript
4
star
64

broccoli-middleware

Broccoli asset builder middleware
HTML
4
star
65

ember-cli-babili

JavaScript
4
star
66

ember-cli-update-codemods-manifest

Master list of codemods and their instructions used by ember-cli-update
JavaScript
4
star
67

amd-name-resolver

Algorithm for resolving AMD module names
JavaScript
3
star
68

ember-cli-string-utils

JavaScript
3
star
69

ember-cli-legacy-blueprints

Ember and Ember-Data specific blueprints for ember-cli projects not using the Ember and Ember-Data addons.
JavaScript
3
star
70

ember-cli-lodash-subset

JavaScript
2
star
71

ember-cli-default-packager

Default Packager for Ember CLI. More details in https://github.com/ember-cli/rfcs/pull/110.
TypeScript
2
star
72

codesandbox

Official Ember.js template for codesandbox.io
JavaScript
2
star
73

broccoli-amd-funnel

Funnel based on whether a module is AMD or not
JavaScript
1
star
74

broccoli-builder

JavaScript
1
star
75

calculate-cache-key-for-tree

ember-cli addon tree cache key builder
JavaScript
1
star
76

broccoli-funnel-reducer

JavaScript
1
star
77

app-blueprint-test

JavaScript
1
star
78

ember-cli-preprocess-registry

JavaScript
1
star
79

ember-cli-import-polyfill

Backports newer addon import API to older ember-cli versions.
JavaScript
1
star
80

node-modules-path

JavaScript
1
star
81

ember-build-utilities

A suite of build utilities for constructing Ember CLI build pipelines
JavaScript
1
star
82

ember-try-config

Config helper for ember-try
JavaScript
1
star
83

broccoli-config-replace

Simple templating using a config.json and regex patterns.
JavaScript
1
star
84

ember-cli-changelog

Tool used to generate changelogs for ember-cli.
JavaScript
1
star
85

create-ember-addon

yarn create ember-addon <name>
JavaScript
1
star