Skip to content

Commit

Permalink
Use karma framework for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Jul 26, 2021
1 parent 6828e71 commit 92dec4b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
47 changes: 47 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = function (config) {
config.set({
basePath: '',

// frameworks to use
// available frameworks: https://www.npmjs.com/search?q=keywords:karma-adapter
frameworks: ['mocha', 'proclaim'],

// list of files / patterns to load in the browser
files: [
'bag.js',
'test/**/*.js',
{ pattern: 'test/fixtures/*', included: false }
],

// webserver path => real path mapping
proxies: {
'/fixtures': '/base/test/fixtures'
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://www.npmjs.com/search?q=keywords:karma-reporter
reporters: ['progress'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: ['ChromeHeadless'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
})
}
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "3.0.0",
"scripts": {
"lint": "standardx -v .",
"test": "npm run lint && ./node_modules/.bin/mocha-browser ./test/test.html --server"
"test": "npm run lint && karma start --single-run",
"test-manual": "karma start"
},
"files": [
"bag.js"
Expand All @@ -12,11 +13,12 @@
"repository": "nodeca/bag.js",
"license": "MIT",
"devDependencies": {
"karma": "^6.3.4",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.1",
"karma-proclaim": "^1.0.0",
"lie": "^3.1.0",
"mocha": "^3.1.2",
"mocha-browser": "~ 0.2.0",
"phantomjs": "~ 1.9.20",
"proclaim": "^3.4.0",
"mocha": "^9.0.3",
"standardx": "^7.0.0"
}
}
6 changes: 4 additions & 2 deletions test/test_extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe('extra tests', function () {
})


// this test will fail on Electron because they don't have a limit on localStorage, see
// https://github.com/electron/electron/issues/8337
it('reset localstorage (namespace) when quota exceeded (2.5-5Mb)', function () {
var b = new window.Bag({ stores: ['localstorage'] })

Expand Down Expand Up @@ -78,8 +80,8 @@ describe('extra tests', function () {

it('init without `new` keyword', function () {
/* eslint-disable new-cap */
assert.instanceOf(new window.Bag(), window.Bag)
assert.instanceOf(window.Bag(), window.Bag)
assert.ok(new window.Bag() instanceof window.Bag)
assert.ok(window.Bag() instanceof window.Bag)
})


Expand Down

0 comments on commit 92dec4b

Please sign in to comment.