Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
refactor(test): refactor folder of test/build/ci
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion committed May 8, 2018
1 parent cc57de2 commit f478889
Show file tree
Hide file tree
Showing 167 changed files with 968 additions and 900 deletions.
17 changes: 8 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,19 @@ script:
- node_modules/.bin/gulp promisetest
- yarn promisefinallytest
- yarn test:phantomjs-single
- node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run
- node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run
- node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run
- node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run
- node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-jasmine.conf.js --single-run
- node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-mocha.conf.js --single-run
- node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-selenium3-jasmine.conf.js --single-run
- node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js --single-run
- node_modules/.bin/gulp test/node
- node_modules/.bin/gulp test/node -no-patch-clock
- node_modules/.bin/gulp test/bluebird
- node simple-server.js 2>&1> server.log&
- node ./test/webdriver/test.sauce.js
- node ./test/spec/webdriver/simple-server.js 2>&1> server.log&
- node ./test/spec/webdriver/test.sauce.js
- yarn add [email protected] [email protected] [email protected]
- yarn test:phantomjs-single
- yarn test-mocha-jasmine-bridge-node
- yarn test-mocha-jasmine-bridge-browser
- node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run
- node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run
- node_modules/.bin/karma start ./test/karma/ci/dist/karma-dist-sauce-jasmine3.conf.js --single-run
- node_modules/.bin/karma start ./test/karma/ci/build/karma-build-sauce-selenium3-mocha.conf.js --single-run
- node_modules/.bin/gulp test/node
- node_modules/.bin/gulp test/node -no-patch-clock
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Implements _Zones_ for JavaScript, inspired by [Dart](https://www.dartlang.org/articles/zones/).

> If you're using zone.js via unpkg (i.e. using `https://unpkg.com/zone.js`)
> and you're using any of the following libraries, make sure you import them first
> and you're using any of the following libraries, make sure you import them first
> * 'newrelic' as it patches global.Promise before zone.js does
> * 'async-listener' as it patches global.setTimeout, global.setInterval before zone.js does
Expand Down Expand Up @@ -36,19 +36,19 @@ See this video from ng-conf 2014 for a detailed explanation:
## Standard API support

zone.js patched most standard web APIs (such as DOM events, `XMLHttpRequest`, ...) and nodejs APIs
(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](STANDARD-APIS.md).
(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](./doc/design/STANDARD-APIS.md).

## Nonstandard API support

We are adding support to some nonstandard APIs, such as MediaQuery and
Notification. Please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md) for more details.
Notification. Please see [NON-STANDARD-APIS.md](./doc/design/NON-STANDARD-APIS.md) for more details.

## Modules

zone.js patches the async APIs described above, but those patches will have some overhead.
Starting from zone.js v0.8.9, you can choose which web API module you want to patch.
For more details, please
see [MODULE.md](MODULE.md).
see [MODULE.md](./doc/design/MODULE.md).

## Promise A+ test passed
[![Promises/A+ 1.1 compliant](https://promisesaplus.com/assets/logo-small.png)](https://promisesaplus.com/)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 6 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,8 @@ function nodeTest(specFiles, cb) {
require('./build/lib/node/rollup-main');
var args = process.argv;
if (args.length > 3) {
require('./build/test/test-env-setup-jasmine' + args[3]);
require('./build/test/env/config/test-env-setup-jasmine' + args[3]);
}
var JasmineRunner = require('jasmine');
var JasmineRunner = require('jasmine');
var jrunner = new JasmineRunner();

Expand All @@ -433,12 +432,12 @@ function nodeTest(specFiles, cb) {
}

gulp.task('test/node', ['compile-node'], function(cb) {
var specFiles = ['build/test/node_entry_point.js'];
var specFiles = ['build/test/env/node/node_entry_point.js'];
nodeTest(specFiles, cb);
});

gulp.task('test/bluebird', ['compile-node'], function(cb) {
var specFiles = ['build/test/node_bluebird_entry_point.js'];
var specFiles = ['build/test/env/node/node_bluebird_entry_point.js'];
nodeTest(specFiles, cb);
});

Expand Down Expand Up @@ -498,7 +497,7 @@ gulp.task('changelog', () => {
// run promise aplus test
gulp.task('promisetest', ['build/zone-node.js'], (cb) => {
const promisesAplusTests = require('promises-aplus-tests');
const adapter = require('./promise-adapter');
const adapter = require('./test/spec/promise/promise-adapter');
promisesAplusTests(adapter, {reporter: 'dot'}, function(err) {
if (err) {
cb(err);
Expand All @@ -510,8 +509,8 @@ gulp.task('promisetest', ['build/zone-node.js'], (cb) => {

// check dist file size limitation
gulp.task('filesize', ['build'], (cb) => {
const checker = require('./check-file-size');
const result = checker(require('./file-size-limit.json'));
const checker = require('./scripts/size/check-file-size');
const result = checker(require('./scripts/size/file-size-limit.json'));
if (result) {
cb();
} else {
Expand Down
12 changes: 0 additions & 12 deletions karma-dist-sauce-jasmine3.conf.js

This file was deleted.

30 changes: 9 additions & 21 deletions lib/jasmine/jasmine-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

'use strict';
import {patchJasmineClock} from './jasmine.clock';
import { mappingMochaMethods } from './mocha-bridge/mocha.bdd';
Zone.__load_patch('jasmine', (global: any) => {
const __extends = function(d: any, b: any) {
for (const p in b)
Expand All @@ -24,7 +25,7 @@ Zone.__load_patch('jasmine', (global: any) => {
// not using jasmine, just return;
return;
}
if ((jasmine as any)['__zone_symbol__isMochaBridge']) {
if ((jasmine as any)['__zone_symbol__isBridge']) {
// jasmine is a mock bridge
return;
}
Expand Down Expand Up @@ -61,23 +62,17 @@ Zone.__load_patch('jasmine', (global: any) => {
jasmineEnv[symbol(methodName)] = originalJasmineFn;
jasmineEnv[methodName] = function(
description: string, specDefinitions: Function, timeout: number) {
if (typeof timeout !== 'number') {
timeout = (jasmine as any)[symbol('mochaTimeout')];
}
const wrappedSpecDef = wrapTestInZone(specDefinitions);
return originalJasmineFn.apply(
this,
typeof timeout === 'number' ? [description, wrappedSpecDef, timeout] :
[description, wrappedSpecDef]);
};
});
['beforeEach', 'afterEach'].forEach(methodName => {
['beforeAll', 'afterAll', 'beforeEach', 'afterEach'].forEach(methodName => {
let originalJasmineFn: Function = jasmineEnv[methodName];
jasmineEnv[symbol(methodName)] = originalJasmineFn;
jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) {
if (typeof timeout !== 'number') {
timeout = (jasmine as any)[symbol('mochaTimeout')];
}
const wrappedSpecDef = wrapTestInZone(specDefinitions);
return originalJasmineFn.apply(
this, typeof timeout === 'number' ? [wrappedSpecDef, timeout] : [wrappedSpecDef]);
Expand All @@ -91,19 +86,7 @@ Zone.__load_patch('jasmine', (global: any) => {
*/
function wrapDescribeInZone(describeBody: Function): Function {
return function() {
(jasmine as any)[symbol('mochaTimeout')] = null;
if (this && !this.timeout) {
this.timeout = function(timeout: number) {
(jasmine as any)[symbol('mochaTimeout')] = timeout;
}
}
if (this && !this.skip) {
this.skip = function() {
if (typeof global['pending'] === 'function') {
global['pending']();
}
}
}
mappingMochaMethods(jasmine, global, this);
return syncZone.run(describeBody, this, (arguments as any) as any[]);
};
}
Expand All @@ -119,6 +102,7 @@ Zone.__load_patch('jasmine', (global: any) => {
testBody = fakeAsyncModule.fakeAsync(testBody);
}
}
mappingMochaMethods(jasmine, global, applyThis);
if (done) {
return testProxyZone.run(testBody, applyThis, [done]);
} else {
Expand Down Expand Up @@ -170,6 +154,10 @@ Zone.__load_patch('jasmine', (global: any) => {
// All functions are done, clear the test zone.
this.testProxyZone = null;
this.testProxyZoneSpec = null;
const originalTimeout = (jasmine as any)['__zone_symbol__DEFAULT_TIMEOUT_INTERVAL'];
if (typeof originalTimeout === 'number') {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
}
ambientZone.scheduleMicroTask('jasmine.onComplete', fn);
})(attrs.onComplete);

Expand Down
17 changes: 17 additions & 0 deletions lib/jasmine/mocha-bridge/mocha.bdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,21 @@ export function mappingBDD(Mocha: any, jasmine: any, global: any) {
target[mocha] = global[jasmine];
}
});
}

const symbol = Zone.__symbol__;
export function mappingMochaMethods(jasmine: any, global: any, context: any) {
if (context && !context.timeout) {
context.timeout = function (timeout: number) {
(jasmine as any)['__zone_symbol__DEFAULT_TIMEOUT_INTERVAL'] = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = timeout;
};
}
if (context && !context.skip) {
context.skip = function () {
if (typeof global['pending'] === 'function') {
global['pending']();
}
};
}
}
3 changes: 2 additions & 1 deletion lib/jasmine/mocha-bridge/mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Zone.__load_patch('mocha-bridge', (global: any) => {
return;
}
global.Mocha = {};
global.Mocha['__zone_symbol__isJasmineBridge'] = true;
// set a flag to tell global.Mocha is a mock.
global.Mocha['__zone_symbol__isBridge'] = true;
mappingBDD(global.Mocha, global.jasmine, global);
});
2 changes: 1 addition & 1 deletion lib/mocha/jasmine-bridge/jasmine.bdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function mappingBDD(jasmine: any, Mocha: any, global: any) {
const chains = mocha.split('.');
let mochaMethod: any = null;
for (let i = 0; i < chains.length; i++) {
mochaMethod = mochaMethod ? mochaMethod[chains[i]] : Mocha[chains[i]];
mochaMethod = mochaMethod ? mochaMethod[chains[i]] : global[chains[i]];
}
global[map.jasmine] = jasmine[map.jasmine] = function() {
const args = Array.prototype.slice.call(arguments);
Expand Down
1 change: 1 addition & 0 deletions lib/mocha/jasmine-bridge/jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Zone.__load_patch('jasmine2mocha', (global: any) => {
}
// create a jasmine global object
jasmine = global['jasmine'] = {};
jasmine['__zone_symbol__isBridge'] = true;
// BDD mapping
mappingBDD(jasmine, global.Mocha, global);

Expand Down
2 changes: 1 addition & 1 deletion lib/mocha/mocha-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Zone.__load_patch('Mocha', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
return;
}

if (Mocha['__zone_symbol__isJasmineBridge']) {
if (Mocha['__zone_symbol__isBridge']) {
return;
}

Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@
"ci": "npm run lint && npm run format && npm run promisetest && npm run test:single && npm run test-node",
"closure:test": "scripts/closure/closure_compiler.sh",
"format": "gulp format:enforce",
"karma-jasmine": "karma start karma-build-jasmine.conf.js",
"karma-jasmine:phantomjs": "karma start karma-build-jasmine-phantomjs.conf.js --single-run",
"karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run",
"karma-jasmine": "karma start ./test/karma/common/build/karma-build-jasmine.conf.js",
"karma-jasmine:phantomjs": "karma start ./test/karma/common/build/karma-build-jasmine-phantomjs.conf.js --single-run",
"karma-jasmine:single": "karma start ./test/karma/common/build/karma-build-jasmine.conf.js --single-run",
"karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client",
"karma-jasmine-phantomjs:autoclose": "npm run karma-jasmine:phantomjs && npm run ws-client",
"lint": "gulp lint",
"prepublish": "tsc && gulp build",
"promisetest": "gulp promisetest",
"promisefinallytest": "mocha promise.finally.spec.js",
"promisefinallytest": "mocha ./test/spec/promise/promise.finally.spec.js",
"webdriver-start": "webdriver-manager update && webdriver-manager start",
"webdriver-http": "node simple-server.js",
"webdriver-test": "node test/webdriver/test.js",
"webdriver-sauce-test": "node test/webdriver/test.sauce.js",
"ws-client": "node ./test/ws-client.js",
"ws-server": "node ./test/ws-server.js",
"webdriver-http": "node test/spec/webdriver/simple-server.js",
"webdriver-test": "node test/spec/webdriver/test.js",
"webdriver-sauce-test": "node test/spec/webdriver/test.sauce.js",
"ws-client": "node ./test/env/websocket/ws-client.js",
"ws-server": "node ./test/env/websocket/ws-server.js",
"tsc": "tsc -p .",
"tsc:w": "tsc -w -p .",
"tslint": "tslint -c tslint.json 'lib/**/*.ts'",
"test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine\"",
"test:phantomjs": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:phantomjs\"",
"test:phantomjs-single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine-phantomjs:autoclose\"",
"test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"",
"test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-dist-jasmine.conf.js\"",
"test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start ./test/karma/common/dist/karma-dist-jasmine.conf.js\"",
"test-node": "gulp test/node",
"test-bluebird": "gulp test/bluebird",
"test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-mocha.conf.js\"",
"test-mocha-jasmine-bridge-browser": "npm run tsc && concurrently \"npm run ws-server\" \"karma start karma-build-mocha-jasmine-bridge.conf.js\"",
"test-mocha-jasmine-bridge-node": "npm run tsc && mocha ./build/test/mocha/mocha-node-test-entry-point.js",
"test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start ./test/karma/common/build/karma-build-mocha.conf.js\"",
"test-mocha-jasmine-bridge-browser": "npm run tsc && concurrently \"npm run ws-server\" \"karma start ./test/karma/common/build/karma-build-mocha-jasmine-bridge.conf.js\"",
"test-mocha-jasmine-bridge-node": "npm run tsc && mocha ./build/test/spec/mocha/mocha-node-test-entry-point.js",
"serve": "python -m SimpleHTTPServer 8000"
},
"repository": {
Expand Down
Loading

0 comments on commit f478889

Please sign in to comment.