Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
Add karma test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Apr 30, 2020
1 parent 70f8320 commit 5e05e32
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
23 changes: 23 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = function(config) {
config.set({
frameworks: ['mocha', 'karma-typescript'],
files: ['src/**/*.ts', 'test/**/!(integration)*.ts'],
preprocessors: {
'**/*.ts': ['karma-typescript'],
},
plugins: ['karma-mocha', 'karma-typescript', 'karma-chrome-launcher', 'karma-firefox-launcher'],
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /\.spec\.ts$/,
},
},
colors: true,
reporters: ['progress', 'karma-typescript'],
browsers: ['FirefoxHeadless', 'ChromeHeadless'],
singleRun: true,
concurrency: Infinity,
// Fail after timeout
browserDisconnectTimeout: 100000,
browserNoActivityTimeout: 100000,
})
}
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"lint": "npm run format && npm run tslint && npm run tsc",
"lint:fix": "npm run format:fix && npm run tslint:fix && npm run tsc",
"unitTests": "mocha --reporter spec --require ts-node/register test/*.spec.ts",
"test": "npm run lint && npm run build && npm run unitTests",
"test:fix": "npm run lint:fix && npm run unitTests",
"webtest": "browserify test/max.js | testling -u"
"test": "npm run lint && npm run build && npm run unitTests && npm run test:browser",
"test:browser": "karma start karma.conf.js",
"test:fix": "npm run lint:fix && npm run unitTests"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -61,7 +61,12 @@
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.2",
"husky": "^2.1.0",
"mocha": "4.1.0",
"karma": "^5.0.2",
"karma-chrome-launcher": "^2.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^2.0.0",
"karma-typescript": "^4.1.1",
"mocha": "7.1.2",
"nyc": "^15.0.1",
"prettier": "^1.15.2",
"ts-node": "^8.9.1",
Expand Down
11 changes: 7 additions & 4 deletions test/dataTypes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { version } from 'process'
import * as assert from 'assert'
import * as RLP from '../src'
const BN = require('bn.js')
const Buffer = require('buffer').Buffer // needed for karma

describe('invalid rlps', function() {
it('should not crash on an invalid rlp', function() {
Expand Down Expand Up @@ -64,10 +65,12 @@ describe('RLP encoding (list):', function() {

describe('RLP encoding (BigInt):', function() {
before(function() {
const nodeVersionNumber = Number(version.match(/^v([0-9]+)/)![1])
if (nodeVersionNumber < 10) {
// tslint:disable-next-line no-invalid-this
this.skip()
if (version) {
const nodeVersionNumber = Number(version.match(/^v([0-9]+)/)![1])
if (nodeVersionNumber < 10) {
// tslint:disable-next-line no-invalid-this
this.skip()
}
}
})
it('should encode a BigInt value', function() {
Expand Down

0 comments on commit 5e05e32

Please sign in to comment.