Skip to content

Commit

Permalink
Merge pull request #312 from emberjs/update-try-config
Browse files Browse the repository at this point in the history
Update ember-try config to avoid bower for Ember channels.
  • Loading branch information
rwjblue authored Feb 11, 2018
2 parents 1d54eae + e9d8648 commit 8371c60
Show file tree
Hide file tree
Showing 6 changed files with 375 additions and 220 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ env:
- EMBER_TRY_SCENARIO=ember-lts-2.4
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-lts-2.12
- EMBER_TRY_SCENARIO=ember-lts-2.16
- EMBER_TRY_SCENARIO=ember-lts-2.18
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
Expand Down
4 changes: 4 additions & 0 deletions addon-test-support/ember-qunit/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ let Adapter = Ember.Test.Adapter.extend({
done();
}
},

// clobber default implementation of `exception` will be added back for Ember
// < 2.17 just below...
exception: null,
});

// Ember 2.17 and higher do not require the test adapter to have an `exception`
Expand Down
228 changes: 116 additions & 112 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,113 +1,117 @@
/* eslint-env node */
module.exports = {
useYarn: true,
scenarios: [
{
name: 'ember-2.0',
bower: {
dependencies: {
ember: '~2.0.0',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-lts-2.4',
bower: {
dependencies: {
ember: 'components/ember#lts-2-4',
},
resolutions: {
ember: 'lts-2-4',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-lts-2.8',
bower: {
dependencies: {
ember: 'components/ember#lts-2-8',
},
resolutions: {
ember: 'lts-2-8',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-lts-2.12',
npm: {
devDependencies: {
'ember-source': '~2.12.0',
},
},
},
{
name: 'ember-release',
bower: {
dependencies: {
ember: 'components/ember#release',
},
resolutions: {
ember: 'release',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-beta',
bower: {
dependencies: {
ember: 'components/ember#beta',
},
resolutions: {
ember: 'beta',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-canary',
bower: {
dependencies: {
ember: 'components/ember#canary',
},
resolutions: {
ember: 'canary',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-default',
npm: {
devDependencies: {},
},
},
],
/* eslint-env node, es6 */
'use strict';

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

module.exports = function() {
return Promise.all([
getChannelURL('release'),
getChannelURL('beta'),
getChannelURL('canary'),
]).then(urls => {
return {
useYarn: true,
scenarios: [
{
name: 'ember-2.0',
bower: {
dependencies: {
ember: '~2.0.0',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-lts-2.4',
bower: {
dependencies: {
ember: 'components/ember#lts-2-4',
},
resolutions: {
ember: 'lts-2-4',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-lts-2.8',
bower: {
dependencies: {
ember: 'components/ember#lts-2-8',
},
resolutions: {
ember: 'lts-2-8',
},
},
npm: {
devDependencies: {
'ember-source': null,
},
},
},
{
name: 'ember-lts-2.12',
npm: {
devDependencies: {
'ember-source': '~2.12.0',
},
},
},
{
name: 'ember-lts-2.16',
npm: {
devDependencies: {
'ember-source': '~2.16.0',
},
},
},
{
name: 'ember-lts-2.18',
npm: {
devDependencies: {
'ember-source': '~2.18.0',
},
},
},
{
name: 'ember-release',
npm: {
devDependencies: {
'ember-source': urls[0],
},
},
},
{
name: 'ember-beta',
npm: {
devDependencies: {
'ember-source': urls[1],
},
},
},
{
name: 'ember-canary',
npm: {
devDependencies: {
'ember-source': urls[2],
},
},
},
{
name: 'ember-default',
npm: {
devDependencies: {},
},
},
],
};
});
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"ember-disable-prototype-extensions": "^1.1.2",
"ember-load-initializers": "^1.0.0",
"ember-resolver": "^4.0.0",
"ember-source": "~2.15.0",
"ember-source": "~2.18.0",
"ember-source-channel-url": "^1.0.1",
"ember-try": "^0.2.23",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-disable-features": "^0.1.3",
"eslint-plugin-prettier": "^2.3.1",
Expand Down
32 changes: 30 additions & 2 deletions tests/unit/unhandled-rejection-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,47 @@ const HAS_NATIVE_PROMISE = typeof Promise !== 'undefined';
const HAS_UNHANDLED_REJECTION_HANDLER = 'onunhandledrejection' in window;

module('unhandle promise rejections', function(hooks) {
let WINDOW_ONERROR;

hooks.beforeEach(function(assert) {
let originalPushResult = assert.pushResult;
// capturing this outside of module scope to ensure we grab
// the test frameworks own window.onerror to reset it
WINDOW_ONERROR = window.onerror;

// this catches the native promise unhandled rejection case because QUnit
// dispatches these to `assert.pushResult`, so we handle the failure being
// pushed and convert it to a passing assertion
//
// Also, on Ember < 2.17 this is called for the RSVP unhandled rejection
// case (because it goes through Adapter.exception).
assert._originalPushResult = assert.pushResult;
assert.pushResult = function(resultInfo) {
// Inverts the result so we can test failing assertions
resultInfo.result = !resultInfo.result;
resultInfo.message = `Failed: ${resultInfo.message}`;
originalPushResult(resultInfo);
this._originalPushResult(resultInfo);
};
});

hooks.afterEach(function() {
window.onerror = WINDOW_ONERROR;
});

test('RSVP promises cause an unhandled rejection', function(assert) {
let done = assert.async();

window.onerror = message => {
assert._originalPushResult({
result: /whoops!/.test(message),
actual: message,
expected: 'to include `whoops!`',
message:
'error should bubble out to window.onerror, and therefore fail tests (due to QUnit implementing window.onerror)',
});

return true; // prevent "bubbling" and therefore failing the test
};

// ensure we do not exit this test until the assertion has happened
setTimeout(done, 10);

Expand Down
Loading

0 comments on commit 8371c60

Please sign in to comment.