-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 17fab50
Showing
7 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Demo ts-lint recompiling TypeScript | ||
|
||
````bash | ||
node --inspect --debug-brk node_modules/.bin/jest --verbose --runInBand | ||
```` | ||
|
||
Sample test output: | ||
|
||
```` | ||
-> % node node_modules/.bin/jest --verbose --runInBand | ||
PASS src/__tests__/simple-error.ts (5.977s) | ||
ts-jest being slow | ||
✓ throwing 1000 Errors (4693ms) | ||
✓ throwing 1000 Errors, not touching Error.stack (4ms) | ||
PASS src/__tests__/slow.ts | ||
ts-jest being slow | ||
✓ creates many Timeout errors (2227ms) | ||
Test Suites: 2 passed, 2 total | ||
Tests: 3 passed, 3 total | ||
Snapshots: 0 total | ||
Time: 9.163s | ||
Ran all test suites. | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "ts-jest-slow", | ||
"version": "0.0.1", | ||
"engines": { | ||
"node": ">=6.10" | ||
}, | ||
"scripts": { | ||
"start": "npm run compile && node build/app.js", | ||
"build": "npm run compile && cp config.json build", | ||
"compile": "rm -rf ./build && tsc -p tsconfig-prod.json --diagnostics --pretty", | ||
"compile:watch": "rm -rf ./build && tsc -p tsconfig.json --watch", | ||
"test": "jest --forceExit --verbose" | ||
}, | ||
"devDependencies": { | ||
"jest": "^20.0.4", | ||
"@types/jest": "^20.0.5", | ||
"ts-jest": "^20.0.7", | ||
"typescript": "^2.4.1" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", "ts" | ||
], | ||
"transform": { | ||
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "/__tests__/.*\\.(ts|tsx|js)$", | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/", | ||
"<rootDir>/build/" | ||
] | ||
}, | ||
"dependencies": { | ||
"@kwonoj/rxjs-testscheduler-compat": "^1.0.2", | ||
"rxjs": "^5.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import "jest"; | ||
import "../index"; | ||
|
||
describe("ts-jest being slow", () => { | ||
|
||
let times = 1000; | ||
|
||
it(`throwing ${times} Errors`, () => { | ||
const errors: Error[] = []; | ||
for (let i = 0; i < times; i++) { | ||
try { | ||
throw new Error("Doesn't matter"); | ||
} catch (e) { | ||
e.stack += "dummy"; | ||
// do nothing | ||
errors.push(e); | ||
} | ||
} | ||
}) | ||
|
||
it(`throwing ${times} Errors, not touching Error.stack`, () => { | ||
const errors: Error[] = []; | ||
for (let i = 0; i < times; i++) { | ||
try { | ||
throw new Error("Doesn't matter"); | ||
} catch (e) { | ||
// do nothing | ||
errors.push(e); | ||
} | ||
} | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import "jest"; | ||
import { TestScheduler } from "@kwonoj/rxjs-testscheduler-compat"; | ||
import { FooBar } from "../index"; | ||
|
||
describe("ts-jest being slow", () => { | ||
|
||
it("creates many Timeout errors", () => { | ||
let scheduler = new TestScheduler() | ||
let foobar = new FooBar(scheduler, 1000); | ||
let results = scheduler.startScheduler(() => foobar.obs, { | ||
created: 0, | ||
subscribed: 0, | ||
unsubscribed: 1000 * 60, | ||
}); | ||
expect(results.messages).toHaveLength(60 - 2); | ||
// let sum = 0; | ||
// for (let i = 0; i < 1000 * 1000; i++) { | ||
// sum += eval("1 + { field: 2 }.field"); | ||
// } | ||
}) | ||
|
||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Observable } from "rxjs/Observable"; | ||
import { Scheduler } from "rxjs/Scheduler"; | ||
|
||
import "rxjs/add/observable/defer"; | ||
import "rxjs/add/observable/from"; | ||
import "rxjs/add/observable/timer"; | ||
import "rxjs/add/observable/range"; | ||
import "rxjs/add/observable/interval"; | ||
import "rxjs/add/observable/merge"; | ||
import "rxjs/add/observable/of"; | ||
import "rxjs/add/operator/bufferCount"; | ||
import "rxjs/add/operator/catch"; | ||
import "rxjs/add/operator/concat"; | ||
import "rxjs/add/operator/concatMap"; | ||
import "rxjs/add/operator/debounceTime"; | ||
import "rxjs/add/operator/do"; | ||
import "rxjs/add/operator/filter"; | ||
import "rxjs/add/operator/groupBy"; | ||
import "rxjs/add/operator/map"; | ||
import "rxjs/add/operator/merge"; | ||
import "rxjs/add/operator/mergeMap"; | ||
import "rxjs/add/operator/publish"; | ||
import "rxjs/add/operator/scan"; | ||
import "rxjs/add/operator/share"; | ||
import "rxjs/add/operator/startWith"; | ||
import "rxjs/add/operator/take"; | ||
import "rxjs/add/operator/takeUntil"; | ||
import "rxjs/add/operator/timeout"; | ||
import "rxjs/add/operator/toPromise"; | ||
import "rxjs/add/operator/zip"; | ||
|
||
export function box<T>(stuff: T) { | ||
return [stuff]; | ||
} | ||
|
||
export class FooBar { | ||
public obs: Observable<number> | ||
constructor(scheduler: Scheduler, time: number = 1000) { | ||
this.obs = Observable | ||
.interval(time, scheduler) | ||
.flatMap(() => Observable.of(1) | ||
.delay(time * 2, scheduler) | ||
.timeout(time, scheduler) | ||
.ignoreElements() | ||
.catch(e => Observable.of(e)) | ||
) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"module": "commonjs", | ||
"target": "es6", | ||
"moduleResolution": "node", | ||
"strictNullChecks": true, | ||
"lib": [ | ||
"es2015" | ||
], | ||
"types": [ | ||
"jest" | ||
], | ||
"outDir": "build", | ||
"declaration": false | ||
}, | ||
"include": [ | ||
"src" | ||
], | ||
"compileOnSave": true | ||
} |