Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 665627e

Browse files
author
Bryan Mikaelian
committed
Move tests to typescript
1 parent 9495826 commit 665627e

23 files changed

+1217
-112
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
paths:
3434
- node_modules
3535
- run: yarn run tsc --declaration
36-
- run: yarn run karma start karma.conf.coverage.js
36+
- run: yarn run karma start karma.conf.coverage.ts
3737
- store_test_results:
3838
path: junit-reports
3939
- run: yarn run codecov

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ KARMA := node_modules/.bin/karma
99
##
1010

1111
LIBS = $(shell find lib -type f -name "*.js")
12-
TESTS = $(shell find test -type f -name "*.test.js")
13-
SUPPORT = $(wildcard karma.conf*.js)
12+
TESTS = $(shell find test -type f -name "*.test.ts")
13+
SUPPORT = $(wildcard karma.conf*.ts)
1414
ALL_FILES = $(LIBS) $(TESTS) $(SUPPORT)
1515

1616
##
@@ -29,9 +29,9 @@ KARMA_FLAGS += --browsers $(BROWSERS)
2929
endif
3030

3131
ifdef CI
32-
KARMA_CONF ?= karma.conf.ci.js
32+
KARMA_CONF ?= karma.conf.ci.ts
3333
else
34-
KARMA_CONF ?= karma.conf.js
34+
KARMA_CONF ?= karma.conf.ts
3535
endif
3636

3737
# Mocha flags.
File renamed without changes.
File renamed without changes.

karma.conf.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

karma.conf.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* eslint-env node */
2+
'use strict';
3+
4+
// 10 minutes
5+
var TEST_TIMEOUT = 10 * 60 * 1000;
6+
7+
module.exports = function(config) {
8+
config.set({
9+
files: [
10+
{ pattern: 'test/support/*.html', included: false },
11+
'test/support/global.ts', // NOTE: This must run before all tests
12+
'test/**/*.test.ts'
13+
],
14+
browsers: ['ChromeHeadless'],
15+
16+
singleRun: true,
17+
18+
frameworks: ['mocha', 'karma-typescript'],
19+
20+
reporters: ['spec'],
21+
22+
preprocessors: {
23+
'test/**/*.ts': 'karma-typescript'
24+
},
25+
26+
browserNoActivityTimeout: TEST_TIMEOUT,
27+
28+
client: {
29+
mocha: {
30+
grep: process.env.GREP,
31+
timeout: TEST_TIMEOUT
32+
}
33+
},
34+
35+
browserify: {
36+
debug: true
37+
},
38+
39+
karmaTypescriptConfig: {
40+
bundlerOptions: {
41+
transforms: [
42+
require('karma-typescript-es6-transform')({
43+
presets: [
44+
['@babel/preset-env', {
45+
debug: true,
46+
include: ["es.map", "es.set"],
47+
corejs: { version: 3, proposals: true },
48+
targets: "ie > 8, defaults"
49+
}]
50+
]
51+
})
52+
]
53+
},
54+
compilerOptions: {
55+
module: "commonjs",
56+
target: "ES5",
57+
allowJs: false,
58+
},
59+
include: ['test'],
60+
exclude: ['node_modules', 'lib', 'test-e2e']
61+
}
62+
});
63+
};

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"@types/node-fetch": "^2.5.7",
7474
"browserify": "13.0.0",
7575
"browserify-istanbul": "^3.0.1",
76+
"buffer": "^4.9.2",
7677
"codeceptjs": "^2.6.5",
7778
"codecov": "^3.7.2",
7879
"compat-trigger-event": "^1.0.0",
@@ -96,6 +97,8 @@
9697
"karma-sauce-launcher": "^1.2.0",
9798
"karma-spec-reporter": "0.0.32",
9899
"karma-summary-reporter": "^1.8.0",
100+
"karma-typescript": "^5.1.0",
101+
"karma-typescript-es6-transform": "^5.1.0",
99102
"lint-staged": "^7.2.0",
100103
"lodash": "^4.17.15",
101104
"mocha": "^2.2.5",
@@ -123,5 +126,9 @@
123126
"transform": [
124127
"package-json-versionify"
125128
]
129+
},
130+
"resolutions": {
131+
"buffer": "^4.9.2",
132+
"typescript": "^4.0.2"
126133
}
127134
}
File renamed without changes.

test/clone.test.js renamed to test/clone.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('clone', function() {
3535
assert.notStrictEqual(cloned.a, input.a);
3636
assert.notStrictEqual(cloned.a.b, input.a.b);
3737
assert.notStrictEqual(cloned.a.b[2], input.a.b[2]);
38-
assert.strictEqual(cloned.a.b[2].getTime(), input.a.b[2].getTime());
38+
assert.strictEqual(cloned.a.b[2].getTime(), (input.a.b[2] as Date).getTime());
3939
assert.deepEqual(cloned.a.b[3], input.a.b[3]);
4040
assert.notStrictEqual(cloned.a.b[3], input.a.b[3]);
4141
});
File renamed without changes.

0 commit comments

Comments
 (0)