Run TS as a require hook for tests instead of precompile

This commit is contained in:
Sindre Sorhus 2019-02-04 02:37:14 +07:00
parent 3c847be5a0
commit 9683cd7fd9
3 changed files with 25 additions and 11 deletions

View file

@ -9,15 +9,15 @@
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",
"url": "sindresorhus.com" "url": "sindresorhus.com"
}, },
"main": "dist/index.js", "main": "dist",
"engines": { "engines": {
"node": ">=6" "node": ">=6"
}, },
"scripts": { "scripts": {
"lint": "tslint --format stylish --project .", "lint": "tslint --format stylish --project .",
"build": "del dist && tsc", "build": "del dist && tsc",
"test": "npm run lint && npm run build && ava dist/tests", "test": "npm run lint && ava",
"prepublish": "npm run build && del dist/tests" "prepublishOnly": "npm run build"
}, },
"files": [ "files": [
"dist" "dist"
@ -46,18 +46,29 @@
"devDependencies": { "devDependencies": {
"@sindresorhus/tsconfig": "^0.1.0", "@sindresorhus/tsconfig": "^0.1.0",
"@types/jsdom": "^11.12.0", "@types/jsdom": "^11.12.0",
"@types/node": "^10.12.10", "@types/node": "^10.12.21",
"@types/tempy": "^0.2.0", "@types/tempy": "^0.2.0",
"@types/zen-observable": "^0.8.0", "@types/zen-observable": "^0.8.0",
"ava": "^0.25.0", "ava": "^1.2.0",
"del-cli": "^1.1.0", "del-cli": "^1.1.0",
"jsdom": "^11.6.2", "jsdom": "^11.6.2",
"rxjs": "^6.3.3", "rxjs": "^6.4.0",
"tempy": "^0.2.1", "tempy": "^0.2.1",
"ts-node": "^8.0.2",
"tslint": "^5.9.1", "tslint": "^5.9.1",
"tslint-xo": "^0.10.0", "tslint-xo": "^0.10.0",
"typescript": "^3.2.1", "typescript": "^3.3.1",
"zen-observable": "^0.8.8" "zen-observable": "^0.8.8"
}, },
"types": "dist/index.d.ts" "types": "dist",
"ava": {
"babel": false,
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
}
} }

View file

@ -4,7 +4,7 @@ import Stream from 'stream';
import util from 'util'; import util from 'util';
import tempy from 'tempy'; import tempy from 'tempy';
import {URL} from 'url'; import {URL} from 'url';
import test, {TestContext, Context} from 'ava'; import test, {ExecutionContext} from 'ava';
import {JSDOM} from 'jsdom'; import {JSDOM} from 'jsdom';
import {Subject, Observable} from 'rxjs'; import {Subject, Observable} from 'rxjs';
import ZenObservable from 'zen-observable'; import ZenObservable from 'zen-observable';
@ -377,7 +377,7 @@ const types = new Map<string, Test>([
]); ]);
// This ensures a certain method matches only the types it's supposed to and none of the other methods' types // This ensures a certain method matches only the types it's supposed to and none of the other methods' types
const testType = (t: TestContext & Context<unknown>, type: string, exclude?: string[]) => { const testType = (t: ExecutionContext, type: string, exclude?: string[]) => {
const testData = types.get(type); const testData = types.get(type);
if (testData === undefined) { if (testData === undefined) {

View file

@ -9,5 +9,8 @@
"esnext.asynciterable", "esnext.asynciterable",
"dom" "dom"
] ]
} },
"include": [
"source"
]
} }