Skip to content

Turn experiments object into a function - #7961

Merged
rwjblue merged 1 commit into
ember-cli:masterfrom
dcyriller:experiments-func
Aug 7, 2018
Merged

rwjblue merged 1 commit into
ember-cli:masterfrom
dcyriller:experiments-func

Conversation

@dcyriller

@dcyriller dcyriller commented Aug 6, 2018 •

Copy link
Copy Markdown
Contributor

When testing an experiment in ember-cli scope, a new CI scenario is the go-to solution. This involves scopping tests like this:

// in ember-cli
if (experiments.MY_EXPERIMENT) {
  describe('my experiment module', ...)
  // or
  module('my experiment module', ...)
} else {
  describe('regular module', ...)
  // or
  module('regular module', ...)
}

But when testing an experiment outside of ember-cli scope, things get different. And we may want to be able to test in sequence:

// in ember-data or in another addon
describe('my addon blueprint', {
  it('works - in a classic app', ...);

  it('works - in a MU app', ...);
})

The issue is: as an object, experiments is cached between the two tests (run on the same process). In these scenarios, we need not to cache the object, hence the function.

@dcyriller

Copy link
Copy Markdown
Contributor Author

A use of this PR would be here ember-cli/ember-cli-blueprint-test-helpers#153

@rwjblue

rwjblue commented Aug 6, 2018 •

Copy link
Copy Markdown
Member

I am not opposed to changing this, but I would prefer a slightly different API.

Seems like we can make this work:

const { isExperimentEnabled } = require('./lib/experiments');

if (isExperimentEnabled('MODULE_UNIFICATION')) {

}

What do you think?

@dcyriller

Copy link
Copy Markdown
Contributor Author

It sounds more consistent indeed. I just updated the PR.

@rwjblue rwjblue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems great to me.

@twokul twokul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apart from failing tests, lgtm

@dcyriller

Copy link
Copy Markdown
Contributor Author

I manually relaunched the tests. One test suite is still failing, it's the one that generates coverage. But it's also failing on master.

@rwjblue
rwjblue requested a review from stefanpenner August 6, 2018 22:50
When testing an experiment in `ember-cli` scope, a new CI scenario seems
to be the go-to solution. This involves scopping tests like this:
```js
if (experiments.MY_EXPERIMENT) {
  describe('my experiment module', ...)
  // or
  module('my experiment module', ...)
} else {
  describe('regular module', ...)
  // or
  module('regular module', ...)
}
```

But when testing an experiment outside of `ember-cli` scope, things get
different. And we may want to be able to do:

```js
describe('my addon blueprint', {
  it('works - in a classic app', ...);

  it('works - in a MU app', ...);
})
```

The issue is: as an object, `experiments` is cached between the two
tests (run on the same process). In these scenarios, we need not to
cache the object, hence the function.
@rwjblue
rwjblue merged commit 6a4c515 into ember-cli:master Aug 7, 2018
@dcyriller
dcyriller deleted the experiments-func branch August 8, 2018 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants