2016-10-17 04:11:36 +08:00
|
|
|
/* eslint global-require:0 */
|
2016-10-17 07:36:49 +08:00
|
|
|
import _ from 'underscore';
|
2016-10-18 08:59:33 +08:00
|
|
|
|
2017-06-25 16:24:25 +08:00
|
|
|
import ReactTestUtils from 'react-dom/test-utils';
|
2017-09-27 02:33:08 +08:00
|
|
|
import Config from '../../src/config';
|
2017-09-27 02:55:33 +08:00
|
|
|
import SpecLoader from './spec-loader';
|
2017-09-27 02:33:08 +08:00
|
|
|
import TimeReporter from './time-reporter';
|
2017-09-27 02:55:33 +08:00
|
|
|
import GuiReporter from './gui-reporter';
|
2016-10-17 04:11:36 +08:00
|
|
|
import jasmineExports from './jasmine';
|
2017-09-27 02:33:08 +08:00
|
|
|
import ConsoleReporter from './console-reporter';
|
|
|
|
import MasterAfterEach from './master-after-each';
|
|
|
|
import MasterBeforeEach from './master-before-each';
|
2017-09-27 02:55:33 +08:00
|
|
|
import TestConstants from './test-constants';
|
2017-09-27 02:33:08 +08:00
|
|
|
import * as jasmineExtensions from './jasmine-extensions';
|
|
|
|
import * as reactTestUtilsExtensions from './react-test-utils-extensions';
|
2016-10-17 04:11:36 +08:00
|
|
|
|
2017-09-27 02:55:33 +08:00
|
|
|
class SpecRunner {
|
2016-10-17 04:29:10 +08:00
|
|
|
runSpecs(loadSettings) {
|
2017-09-27 02:33:08 +08:00
|
|
|
this.loadSettings = loadSettings;
|
2016-10-17 04:11:36 +08:00
|
|
|
this._extendGlobalWindow();
|
2016-10-17 04:17:34 +08:00
|
|
|
this._setupJasmine();
|
2017-09-27 02:36:58 +08:00
|
|
|
this._setupAppEnv();
|
2016-10-17 07:36:49 +08:00
|
|
|
this._setupWindow();
|
2017-09-27 02:33:08 +08:00
|
|
|
Object.assign(ReactTestUtils, reactTestUtilsExtensions);
|
|
|
|
MasterBeforeEach.setup(this.loadSettings, window.beforeEach);
|
|
|
|
MasterAfterEach.setup(this.loadSettings, window.afterEach);
|
2017-09-27 02:55:33 +08:00
|
|
|
SpecLoader.loadSpecs(this.loadSettings, this.jasmineEnv);
|
2016-10-17 04:29:10 +08:00
|
|
|
this.jasmineEnv.execute();
|
2016-10-17 04:11:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Put jasmine methods on the global scope so they can be used anywhere
|
|
|
|
* without importing jasmine.
|
|
|
|
*/
|
|
|
|
_extendGlobalWindow() {
|
2017-09-27 02:33:08 +08:00
|
|
|
Object.assign(
|
|
|
|
window,
|
|
|
|
{
|
|
|
|
jasmine: jasmineExports.jasmine,
|
|
|
|
|
|
|
|
it: this._makeItAsync(jasmineExports.it),
|
|
|
|
// it: jasmineExports.it,
|
|
|
|
fit: this._makeItAsync(jasmineExports.fit),
|
|
|
|
xit: jasmineExports.xit,
|
|
|
|
runs: jasmineExports.runs,
|
|
|
|
waits: jasmineExports.waits,
|
|
|
|
spyOn: jasmineExports.spyOn,
|
|
|
|
expect: jasmineExports.expect,
|
|
|
|
waitsFor: jasmineExports.waitsFor,
|
|
|
|
describe: jasmineExports.describe,
|
|
|
|
xdescribe: jasmineExports.xdescribe,
|
|
|
|
afterEach: this._makeSurroundAsync(jasmineExports.afterEach),
|
|
|
|
beforeEach: this._makeSurroundAsync(jasmineExports.beforeEach),
|
|
|
|
testNowMoment: jasmineExtensions.testNowMoment,
|
|
|
|
waitsForPromise: jasmineExtensions.waitsForPromise,
|
|
|
|
},
|
2017-09-27 02:55:33 +08:00
|
|
|
TestConstants
|
2017-09-27 02:33:08 +08:00
|
|
|
);
|
2016-10-17 07:36:49 +08:00
|
|
|
|
|
|
|
this.jasmineEnv = jasmineExports.jasmine.getEnv();
|
|
|
|
}
|
|
|
|
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
_runAsync(userFn) {
|
2017-09-27 02:33:08 +08:00
|
|
|
if (!userFn) return true;
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
const resp = userFn.apply(this);
|
|
|
|
if (resp && resp.then) {
|
|
|
|
return jasmineExtensions.waitsForPromise(() => {
|
2017-09-27 02:33:08 +08:00
|
|
|
return resp;
|
|
|
|
});
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
}
|
2017-09-27 02:33:08 +08:00
|
|
|
return resp;
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
_makeItAsync(jasmineIt) {
|
|
|
|
const self = this;
|
|
|
|
return (desc, userFn) => {
|
|
|
|
return jasmineIt(desc, function asyncIt() {
|
2017-09-27 02:33:08 +08:00
|
|
|
self._runAsync.call(this, userFn);
|
|
|
|
});
|
|
|
|
};
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
_makeSurroundAsync(jasmineBeforeAfter) {
|
|
|
|
const self = this;
|
2017-09-27 02:33:08 +08:00
|
|
|
return userFn => {
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
return jasmineBeforeAfter(function asyncBeforeAfter() {
|
2017-09-27 02:33:08 +08:00
|
|
|
self._runAsync.call(this, userFn);
|
|
|
|
});
|
|
|
|
};
|
fix(spec): add support for async specs and disable misbehaving ones
More spec fixes
replace process.nextTick with setTimeout(fn, 0) for specs
Also added an unspy in the afterEach
Temporarily disable specs
fix(spec): start fixing specs
Summary:
This is the WIP fix to our spec runner.
Several tests have been completely commented out that will require
substantially more work to fix. These have been added to our sprint
backlog.
Other tests have been fixed to update to new APIs or to deal with genuine
bugs that were introduced without our knowing!
The most common non-trivial change relates to observing the `NylasAPI` and
`NylasAPIRequest`. We used to observe the arguments to `makeRequest`.
Unfortunately `NylasAPIRequest.run` is argumentless. Instead you can do:
`NylasAPIRequest.prototype.run.mostRecentCall.object.options` to get the
`options` passed into the object. the `.object` property grabs the context
of the spy when it was last called.
Fixing these tests uncovered several concerning issues with our test
runner. I spent a while tracking down why our participant-text-field-spec
was failling every so often. I chose that spec because it was the first
spec to likely fail, thereby requiring looking at the least number of
preceding files. I tried binary searching, turning on and off, several
files beforehand only to realize that the failure rate was not determined
by a particular preceding test, but rather the existing and quantity of
preceding tests, AND the number of console.log statements I had. There is
some processor-dependent race condition going on that needs further
investigation.
I also discovered an issue with the file-download-spec. We were getting
errors about it accessing a file, which was very suspicious given the code
stubs out all fs access. This was caused due to a spec that called an
async function outside ot a `waitsForPromise` block or a `waitsFor` block.
The test completed, the spies were cleaned up, but the downstream async
chain was still running. By the time the async chain finished the runner
was already working on the next spec and the spies had been restored
(causing the real fs access to run).
Juan had an idea to kill the specs once one fails to prevent cascading
failures. I'll implement this in the next diff update
Test Plan: npm test
Reviewers: juan, halla, jackie
Differential Revision: https://phab.nylas.com/D3501
Disable other specs
Disable more broken specs
All specs turned off till passing state
Use async-safe versions of spec functions
Add async test spec
Remove unused package code
Remove canary spec
2016-12-13 04:12:20 +08:00
|
|
|
}
|
|
|
|
|
2016-10-17 07:36:49 +08:00
|
|
|
_setupJasmine() {
|
2017-09-27 02:33:08 +08:00
|
|
|
this._addReporters();
|
|
|
|
this._initializeDOM();
|
2016-10-17 07:36:49 +08:00
|
|
|
this._extendJasmineMethods();
|
2016-10-17 04:11:36 +08:00
|
|
|
|
|
|
|
// On load, this will require "jasmine-focused" which looks up the
|
|
|
|
// global `jasmine` object and extends onto it:
|
2016-10-17 04:17:34 +08:00
|
|
|
// fdescribe, ffdescribe, fffdescribe, fit, ffit, fffit
|
|
|
|
require('jasmine-tagged');
|
|
|
|
|
2016-10-17 07:36:49 +08:00
|
|
|
// On load this will extend jasmine's `beforeEach`
|
|
|
|
require('jasmine-json');
|
2016-10-17 04:17:34 +08:00
|
|
|
}
|
|
|
|
|
2017-09-27 02:36:58 +08:00
|
|
|
_setupAppEnv() {
|
2016-10-17 07:36:49 +08:00
|
|
|
// We need to mock the config even before `beforeEach` runs because it
|
|
|
|
// gets accessed on module definitions
|
2017-09-27 02:33:08 +08:00
|
|
|
const fakePersistedConfig = { env: 'production' };
|
2017-09-27 02:36:58 +08:00
|
|
|
AppEnv.config = new Config();
|
|
|
|
AppEnv.config.settings = fakePersistedConfig;
|
|
|
|
|
|
|
|
AppEnv.restoreWindowDimensions();
|
2017-09-29 05:43:43 +08:00
|
|
|
AppEnv.themes.loadStaticStylesheets();
|
2017-09-27 02:36:58 +08:00
|
|
|
AppEnv.themes.requireStylesheet('../../static/jasmine');
|
|
|
|
AppEnv.themes.initialLoadComplete = true;
|
|
|
|
AppEnv.keymaps.loadKeymaps();
|
2016-10-17 07:36:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
_setupWindow() {
|
|
|
|
window.addEventListener('core:close', () => window.close());
|
|
|
|
window.addEventListener('beforeunload', () => {
|
2017-09-27 02:36:58 +08:00
|
|
|
AppEnv.storeWindowDimensions();
|
|
|
|
return AppEnv.saveSync();
|
2016-10-17 07:36:49 +08:00
|
|
|
});
|
2016-10-17 04:17:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
_addReporters() {
|
|
|
|
const timeReporter = new TimeReporter();
|
|
|
|
const consoleReporter = new ConsoleReporter();
|
|
|
|
|
2017-09-27 02:36:58 +08:00
|
|
|
const loadSettings = AppEnv.getLoadSettings();
|
2017-02-11 07:33:42 +08:00
|
|
|
|
|
|
|
if (loadSettings.jUnitXmlPath) {
|
|
|
|
// jasmine-reporters extends the jasmine global with methods, so needs to
|
|
|
|
// be `required` at runtime. The `jasmine` object has to be attached to the
|
|
|
|
// global scope before it gets extended. This is done in
|
|
|
|
// `_extendGlobalWindow`
|
|
|
|
require('jasmine-reporters');
|
|
|
|
const jUnitXmlReporter = new jasmine.JUnitXmlReporter(loadSettings.jUnitXmlPath, true, true);
|
|
|
|
this.jasmineEnv.addReporter(jUnitXmlReporter);
|
|
|
|
}
|
|
|
|
this.jasmineEnv.addReporter(timeReporter);
|
|
|
|
this.jasmineEnv.addReporter(consoleReporter);
|
2016-10-17 04:17:34 +08:00
|
|
|
|
2017-02-11 07:33:42 +08:00
|
|
|
if (loadSettings.showSpecsInWindow) {
|
2017-09-27 02:55:33 +08:00
|
|
|
this.jasmineEnv.addReporter(GuiReporter);
|
2017-09-27 02:36:58 +08:00
|
|
|
AppEnv.show();
|
2016-10-17 04:17:34 +08:00
|
|
|
} else {
|
2017-02-11 07:33:42 +08:00
|
|
|
// this package's dep `jasmine-focused` also adds methods to the
|
|
|
|
// `jasmine` global
|
|
|
|
// NOTE: this reporter MUST be added last as it exits the test process
|
|
|
|
// when complete, which may result in e.g. your XML output not getting
|
|
|
|
// written to disk if that reporter is added afterward.
|
2017-09-27 02:55:33 +08:00
|
|
|
const TerminalReporter = require('./terminal-reporter').default;
|
2017-02-11 07:33:42 +08:00
|
|
|
|
2017-09-27 02:55:33 +08:00
|
|
|
const terminalReporter = new TerminalReporter();
|
2016-10-17 04:17:34 +08:00
|
|
|
this.jasmineEnv.addReporter(terminalReporter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_initializeDOM() {
|
|
|
|
const div = document.createElement('div');
|
|
|
|
div.id = 'jasmine-content';
|
|
|
|
document.body.appendChild(div);
|
2016-10-17 07:36:49 +08:00
|
|
|
document.querySelector('html').style.overflow = 'initial';
|
|
|
|
document.querySelector('body').style.overflow = 'initial';
|
|
|
|
}
|
|
|
|
|
|
|
|
_extendJasmineMethods() {
|
|
|
|
const jasmine = jasmineExports.jasmine;
|
|
|
|
|
|
|
|
// Use underscore's definition of equality for toEqual assertions
|
|
|
|
jasmine.getEnv().addEqualityTester(_.isEqual);
|
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
jasmine.unspy = jasmineExtensions.unspy;
|
|
|
|
jasmine.attachToDOM = jasmineExtensions.attachToDOM;
|
2016-10-17 07:36:49 +08:00
|
|
|
|
|
|
|
const origEmitObject = jasmine.StringPrettyPrinter.prototype.emitObject;
|
|
|
|
jasmine.StringPrettyPrinter.prototype.emitObject = function emitObject(obj) {
|
|
|
|
if (obj.inspect) {
|
|
|
|
return this.append(obj.inspect());
|
|
|
|
}
|
|
|
|
return origEmitObject.call(this, obj);
|
|
|
|
};
|
2016-10-17 04:17:34 +08:00
|
|
|
}
|
2016-10-17 04:11:36 +08:00
|
|
|
}
|
2017-09-27 02:55:33 +08:00
|
|
|
export default new SpecRunner();
|