Skip to content

Commit

Permalink
Merge pull request #2851 from kwonoj/chore-simplify-test
Browse files Browse the repository at this point in the history
Simplify test script pipeline
  • Loading branch information
kwonoj authored Oct 27, 2017
2 parents 69bae9b + 8d137ac commit 040d951
Show file tree
Hide file tree
Showing 177 changed files with 372 additions and 385 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ coverage/
img/
spec-js/
.nyc_output/
.out/

# Misc
npm-debug.log
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ install:

script:
- if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then echo {} > ./.babelrc && npx danger; fi
- npm run build_spec && npm run test_mocha && node ./node_modules/markdown-doctest/bin/cmd.js
- npm test

after_success:
- if [ "$FULL_VALIDATE" == "true" ]; then npm run cover && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js; fi
- if [ "$FULL_VALIDATE" == "true" ]; then npm run test:cover && npx nyc report --reporter=text-lcov | npx coveralls; fi
- if [ "$FULL_VALIDATE" == "true" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ -n "$SAUCE_ACCESS_KEY" ]; then npm run build_spec_browser && grunt --gruntfile spec/support/mocha.sauce.gruntfile.js; fi
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ install:
- npm install

build_script:
- npm run build_spec
- npm run build_all

test_script:
- npm run cover
- npm test

version: "{build}"
56 changes: 36 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@
"path": "cz-conventional-changelog"
}
},
"nyc": {
"include": [
"src/*.ts",
"src/**/*.ts"
],
"exclude": [
"node_modules",
"dist",
"typings",
"*.d.ts",
"src/**/MiscJSDoc.ts"
],
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"reporter": [
"html"
],
"all": true
},
"lint-staged": {
"*.@(js)": [
"eslint --fix",
Expand All @@ -28,11 +51,8 @@
"build_global": "Build Global package, then minify build",
"build_perf": "Build CJS & Global build, run macro performance test",
"build_test": "Build CJS package & test spec, execute mocha test runner",
"build_cover": "Run lint to current code, build CJS & test spec, execute test coverage",
"build_docs": "Build ESM2015 & global package, create documentation using it",
"build_spec": "Build test specs",
"check_circular_dependencies": "Check codebase has circular dependencies",
"clean_spec": "Clean up existing test spec build output",
"clean_dist_cjs": "Clean up existing CJS package output",
"clean_dist_esm5": "Clean up existing ESM/ES5 package output",
"clean_dist_esm2015": "Clean up existing ESM/ES2015 package output",
Expand All @@ -41,7 +61,6 @@
"compile_dist_cjs": "Compile codebase into CJS module",
"compile_module_esm5": "Compile codebase into ESM/ES5",
"compile_dist_esm2015": "Compile codebase into ESM/ES2015",
"cover": "Execute test coverage",
"lint_perf": "Run lint against performance test suite",
"lint_spec": "Run lint against test spec",
"lint_src": "Run lint against source",
Expand All @@ -51,6 +70,7 @@
"test_mocha": "Execute mocha test runner against existing test spec build",
"test_browser": "Execute mocha test runner on browser against existing test spec build",
"test": "Clean up existing test spec build, build test spec and execute mocha test runner",
"test:cover": "Execute test coverage",
"tests2png": "Generate marble diagram image from test spec",
"watch": "Watch codebase, trigger compile when source code changes"
},
Expand All @@ -68,27 +88,22 @@
"build_global": "npm-run-all clean_dist_global build_esm5_for_rollup && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core clean_dist_esm5_for_rollup",
"build_umd": "npm-run-all clean_dist_global && mkdirp ./dist/global && node ./tools/make-umd-bundle.js && npm-run-all build_closure_core",
"build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf",
"build_test": "shx rm -rf ./dist/ && npm-run-all copy_sources build_cjs generate_packages clean_spec build_spec test_mocha",
"build_cover": "shx rm -rf ./dist/ && npm-run-all build_all build_spec cover",
"build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs clean_spec build_spec tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015",
"build_spec": "tsc --project ./spec --pretty",
"build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015",
"build_spec_browser": "webpack --config spec/support/webpack.mocha.config.js",
"check_circular_dependencies": "madge ./dist/cjs --circular",
"clean_spec": "shx rm -rf spec-js",
"clean_dist": "shx rm -rf ./dist",
"clean_dist_cjs": "shx rm -rf ./dist/cjs",
"clean_dist_esm5": "shx rm -rf ./dist/esm5",
"clean_dist_esm5_for_rollup": "shx rm -rf ./dist/esm5_for_rollup",
"clean_dist_esm2015": "shx rm -rf ./dist/esm2015",
"clean_dist_global": "shx rm -rf ./dist/global",
"commit": "git-cz",
"compile_dist_cjs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --inlineSources --outDir ./dist/cjs --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node -d --declarationDir ./dist/typings",
"compile_dist_esm5": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5 --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_esm2015": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm2015 --target es2015 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_esm2015_for_docs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts ./dist/src/operator/toPromise.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_esm5_for_rollup": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/operator/toPromise.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5_for_rollup --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers",
"compile_dist_cjs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/cjs --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node -d --declarationDir ./dist/typings",
"compile_dist_esm5": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5 --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_esm2015": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm2015 --target es2015 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_esm2015_for_docs": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts ./dist/src/MiscJSDoc.ts -m es2015 --sourceMap --outDir ./dist/es6 --target es2015 -d --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node",
"compile_dist_esm5_for_rollup": "tsc ./dist/src/Rx.ts ./dist/src/add/observable/of.ts -m es2015 --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --sourceMap --outDir ./dist/esm5_for_rollup --target ES5 --diagnostics --pretty --noImplicitAny --noImplicitReturns --noImplicitThis --suppressImplicitAnyIndexErrors --moduleResolution node --noEmitHelpers",
"copy_sources": "mkdirp dist && shx cp -r ./src/ ./dist/src",
"cover": "shx rm -rf dist/cjs && tsc dist/src/Rx.ts dist/src/add/observable/of.ts -m commonjs --lib es5,es2015.iterable,es2015.collection,es2015.promise,dom --outDir dist/cjs --sourceMap --target ES5 -d && nyc --reporter=lcov --reporter=html --exclude=spec/support/**/* --exclude=spec-js/**/* --exclude=node_modules mocha --opts spec/support/default.opts spec-js",
"decision_tree_widget": "cd doc/decision-tree-widget && npm run build && cd ../..",
"doctoc": "doctoc CONTRIBUTING.md",
"generate_packages": "node .make-packages.js",
Expand All @@ -100,11 +115,10 @@
"perf_micro": "node ./perf/micro/index.js",
"prepublish": "shx rm -rf ./typings && typings install && npm run build_all",
"publish_docs": "./publish_docs.sh",
"test_mocha": "mocha --opts spec/support/default.opts spec-js",
"debug_mocha": "node --inspect --debug-brk ./node_modules/.bin/_mocha --opts spec/support/debug.opts spec-js",
"test_browser": "npm-run-all build_spec_browser && opn spec/support/mocha-browser-runner.html",
"test": "npm-run-all clean_spec build_spec test_mocha clean_spec",
"tests2png": "npm run build_spec && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js",
"test": "cross-env TS_NODE_FAST=true mocha --compilers ts:ts-node/register --opts spec/support/coverage.opts \"spec/**/*-spec.ts\"",
"test:cover": "cross-env TS_NODE_FAST=true nyc npm test",
"tests2png": "tsc && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js",
"watch": "watch \"echo triggering build && npm run build_test && echo build completed\" src -d -u -w=15"
},
"repository": {
Expand Down Expand Up @@ -165,6 +179,7 @@
"colors": "1.1.2",
"commitizen": "^2.8.6",
"coveralls": "^2.11.13",
"cross-env": "^5.1.0",
"cz-conventional-changelog": "^1.2.0",
"danger": "^1.1.0",
"doctoc": "^1.0.0",
Expand All @@ -190,7 +205,7 @@
"mocha-in-sauce": "0.0.1",
"npm-run-all": "^4.0.2",
"npm-scripts-info": "^0.3.4",
"nyc": "^10.2.0",
"nyc": "^11.3.0",
"opn-cli": "^3.1.0",
"platform": "^1.3.1",
"promise": "^7.1.1",
Expand All @@ -204,6 +219,7 @@
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"source-map-support": "^0.4.0",
"ts-node": "^3.3.0",
"tslib": "^1.5.0",
"tslint": "^4.4.2",
"typescript": "~2.0.6",
Expand Down
5 changes: 3 additions & 2 deletions spec/Notification-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect } from 'chai';
import * as Rx from '../dist/package/Rx';
import * as Rx from '../src/Rx';
import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const expectObservable;
declare const expectObservable: typeof marbleTestingSignature.expectObservable;
const Notification = Rx.Notification;

/** @test {Notification} */
Expand Down
12 changes: 7 additions & 5 deletions spec/Observable-spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as Rx from '../dist/package/Rx';
import { TeardownLogic } from '../dist/package/Subscription';
import * as Rx from '../src/Rx';
import { TeardownLogic } from '../src/Subscription';
import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports
import { map } from '../dist/package/operators/map';
import { map } from '../src/operators/map';
//tslint:disable-next-line
require('./helpers/test-helper');

declare const { asDiagram, rxTestScheduler };
declare const asDiagram: any, rxTestScheduler: any;
declare const cold: typeof marbleTestingSignature.cold;
declare const expectObservable: typeof marbleTestingSignature.expectObservable;
declare const expectSubscriptions: typeof marbleTestingSignature.expectSubscriptions;
Expand All @@ -15,7 +17,7 @@ const Observable = Rx.Observable;

declare const __root__: any;

function expectFullObserver(val) {
function expectFullObserver(val: any) {
expect(val).to.be.a('object');
expect(val.next).to.be.a('function');
expect(val.error).to.be.a('function');
Expand Down
2 changes: 1 addition & 1 deletion spec/Scheduler-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import * as Rx from '../dist/package/Rx';
import * as Rx from '../src/Rx';

const Scheduler = Rx.Scheduler;

Expand Down
2 changes: 1 addition & 1 deletion spec/Subject-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import * as Rx from '../dist/package/Rx';
import * as Rx from '../src/Rx';
import marbleTestingSignature = require('./helpers/marble-testing'); // tslint:disable-line:no-require-imports

declare const { time };
Expand Down
2 changes: 1 addition & 1 deletion spec/Subscriber-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import * as sinon from 'sinon';
import * as Rx from '../dist/package/Rx';
import * as Rx from '../src/Rx';

const Subscriber = Rx.Subscriber;

Expand Down
2 changes: 1 addition & 1 deletion spec/Subscription-spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import * as Rx from '../dist/package/Rx';
import * as Rx from '../src/Rx';

const Observable = Rx.Observable;
const Subscription = Rx.Subscription;
Expand Down
52 changes: 26 additions & 26 deletions spec/exports-spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { expect } from 'chai';
import { bindCallback } from '../dist/package/observable/bindCallback';
import { bindNodeCallback } from '../dist/package/observable/bindNodeCallback';
import { combineLatest } from '../dist/package/observable/combineLatest';
import { concat } from '../dist/package/observable/concat';
import { defer } from '../dist/package/observable/defer';
import { empty } from '../dist/package/observable/empty';
import { forkJoin } from '../dist/package/observable/forkJoin';
import { from } from '../dist/package/observable/from';
import { fromEvent } from '../dist/package/observable/fromEvent';
import { fromEventPattern } from '../dist/package/observable/fromEventPattern';
import { fromPromise } from '../dist/package/observable/fromPromise';
import { _if } from '../dist/package/observable/if';
import { interval } from '../dist/package/observable/interval';
import { merge } from '../dist/package/observable/merge';
import { never } from '../dist/package/observable/never';
import { of } from '../dist/package/observable/of';
import { onErrorResumeNext } from '../dist/package/observable/onErrorResumeNext';
import { pairs } from '../dist/package/observable/pairs';
import { race } from '../dist/package/observable/race';
import { range } from '../dist/package/observable/range';
import { _throw } from '../dist/package/observable/throw';
import { timer } from '../dist/package/observable/timer';
import { using } from '../dist/package/observable/using';
import { zip } from '../dist/package/observable/zip';
import * as Rx from '../dist/package/Rx';
import { bindCallback } from '../src/observable/bindCallback';
import { bindNodeCallback } from '../src/observable/bindNodeCallback';
import { combineLatest } from '../src/observable/combineLatest';
import { concat } from '../src/observable/concat';
import { defer } from '../src/observable/defer';
import { empty } from '../src/observable/empty';
import { forkJoin } from '../src/observable/forkJoin';
import { from } from '../src/observable/from';
import { fromEvent } from '../src/observable/fromEvent';
import { fromEventPattern } from '../src/observable/fromEventPattern';
import { fromPromise } from '../src/observable/fromPromise';
import { _if } from '../src/observable/if';
import { interval } from '../src/observable/interval';
import { merge } from '../src/observable/merge';
import { never } from '../src/observable/never';
import { of } from '../src/observable/of';
import { onErrorResumeNext } from '../src/observable/onErrorResumeNext';
import { pairs } from '../src/observable/pairs';
import { race } from '../src/observable/race';
import { range } from '../src/observable/range';
import { _throw } from '../src/observable/throw';
import { timer } from '../src/observable/timer';
import { using } from '../src/observable/using';
import { zip } from '../src/observable/zip';
import * as Rx from '../src/Rx';

describe('exports', () => {
it('should have rxjs/observable/bindCallback', () => {
Expand Down Expand Up @@ -121,4 +121,4 @@ describe('exports', () => {
it('should have rxjs/observable/zip', () => {
expect(zip).to.equal(Rx.Observable.zip);
});
});
});
12 changes: 0 additions & 12 deletions spec/helpers/ambient.d.ts

This file was deleted.

10 changes: 5 additions & 5 deletions spec/helpers/marble-testing.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
///<reference path='../../typings/index.d.ts'/>
import { Observable } from '../../dist/package/Observable';
import { SubscriptionLog } from '../../dist/package/testing/SubscriptionLog';
import { ColdObservable } from '../../dist/package/testing/ColdObservable';
import { HotObservable } from '../../dist/package/testing/HotObservable';
import { TestScheduler, observableToBeFn, subscriptionLogsToBeFn } from '../../dist/package/testing/TestScheduler';
import { Observable } from '../../src/Observable';
import { SubscriptionLog } from '../../src/testing/SubscriptionLog';
import { ColdObservable } from '../../src/testing/ColdObservable';
import { HotObservable } from '../../src/testing/HotObservable';
import { TestScheduler, observableToBeFn, subscriptionLogsToBeFn } from '../../src/testing/TestScheduler';

declare const global: any;

Expand Down
39 changes: 21 additions & 18 deletions spec/helpers/test-helper.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
///<reference path='../../typings/index.d.ts'/>
declare const global: any;

import * as Rx from '../../dist/package/Rx';
import { ObservableInput } from '../../dist/package/Observable';
import { root } from '../../dist/package/util/root';
import {$$iterator} from '../../dist/package/symbol/iterator';
import * as Rx from '../../src/Rx';
import { ObservableInput } from '../../src/Observable';
import { root } from '../../src/util/root';
import { $$iterator } from '../../src/symbol/iterator';
import $$symbolObservable from 'symbol-observable';
import { Observable } from '../../src/Observable';

export function lowerCaseO<T>(...args): Rx.Observable<T> {
export function lowerCaseO<T>(...args: Array<any>): Rx.Observable<T> {

const o = {
subscribe: function (observer) {
subscribe: function (observer: any) {
args.forEach(function (v) {
observer.next(v);
});
observer.complete();
}
};

o[$$symbolObservable] = function () {
o[$$symbolObservable] = function (this: any) {
return this;
};

Expand All @@ -30,17 +31,19 @@ export const createObservableInputs = <T>(value: T) => Rx.Observable.of<Observab
Rx.Observable.of<T>(value, Rx.Scheduler.async),
[value],
Promise.resolve(value),
<any>({ [$$iterator]: () => {
const iteratorResults = [
{value, done: false},
{done: true}
];
return {
next: () => {
return iteratorResults.shift();
}
};
}}),
<any>({
[$$iterator]: () => {
const iteratorResults = [
{ value, done: false },
{ done: true }
];
return {
next: () => {
return iteratorResults.shift();
}
};
}
}),
<any>({ [$$symbolObservable]: () => Rx.Observable.of(value) })
);

Expand Down
Loading

0 comments on commit 040d951

Please sign in to comment.