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

Commit 10f178a

Browse files
Move tests to typescript (#191)
1 parent 9495826 commit 10f178a

22 files changed

+334
-79
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 renamed to karma.conf.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,22 @@
55
var TEST_TIMEOUT = 10 * 60 * 1000;
66

77
module.exports = function(config) {
8-
require('ts-node').register({
9-
compilerOptions: {
10-
module: 'commonjs'
11-
}
12-
});
138
config.set({
149
files: [
1510
{ pattern: 'test/support/*.html', included: false },
16-
'test/support/global.js', // NOTE: This must run before all tests
17-
'test/**/*.test.js'
11+
'test/support/global.ts', // NOTE: This must run before all tests
12+
'test/**/*.test.ts'
1813
],
1914
browsers: ['ChromeHeadless'],
2015

2116
singleRun: true,
2217

23-
frameworks: ['browserify', 'mocha'],
18+
frameworks: ['mocha', 'karma-typescript'],
2419

2520
reporters: ['spec'],
2621

2722
preprocessors: {
28-
'test/**/*.js': 'browserify'
23+
'test/**/*.ts': 'karma-typescript'
2924
},
3025

3126
browserNoActivityTimeout: TEST_TIMEOUT,
@@ -39,6 +34,19 @@ module.exports = function(config) {
3934

4035
browserify: {
4136
debug: true
37+
},
38+
39+
karmaTypescriptConfig: {
40+
bundlerOptions: {
41+
sourceMap: true,
42+
},
43+
compilerOptions: {
44+
module: "commonjs",
45+
target: "ES5",
46+
allowJs: false,
47+
},
48+
include: ['test'],
49+
exclude: ['node_modules', 'lib', 'test-e2e/*.ts']
4250
}
4351
});
4452
};

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@
7171
"@types/mocha": "^7.0.2",
7272
"@types/node": "^14.0.6",
7373
"@types/node-fetch": "^2.5.7",
74+
"assert": "1.5.0",
7475
"browserify": "13.0.0",
7576
"browserify-istanbul": "^3.0.1",
77+
"buffer": "^4.9.2",
7678
"codeceptjs": "^2.6.5",
7779
"codecov": "^3.7.2",
7880
"compat-trigger-event": "^1.0.0",
@@ -96,13 +98,14 @@
9698
"karma-sauce-launcher": "^1.2.0",
9799
"karma-spec-reporter": "0.0.32",
98100
"karma-summary-reporter": "^1.8.0",
101+
"karma-typescript": "^5.1.0",
99102
"lint-staged": "^7.2.0",
100103
"lodash": "^4.17.15",
101104
"mocha": "^2.2.5",
102105
"node-fetch": "^2.6.0",
103106
"np": "^3.0.4",
104107
"prettier-eslint-cli": "^4.7.1",
105-
"proclaim": "^3.4.1",
108+
"proclaim": "^3.5.1",
106109
"puppeteer": "^3.3.0",
107110
"sinon": "^1.7.3",
108111
"snyk": "^1.83.0",
@@ -123,5 +126,9 @@
123126
"transform": [
124127
"package-json-versionify"
125128
]
129+
},
130+
"resolutions": {
131+
"buffer": "^4.9.2",
132+
"assert": "1.5.0"
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.
File renamed without changes.

0 commit comments

Comments
 (0)