Created
July 29, 2018 14:35
-
-
Save peterver/42c32e66e03d3d3a609b19b1ecc4b50f to your computer and use it in GitHub Desktop.
Karma Setup with Chrome Headless + Jasmine + Webpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { guid } from '../../src/hash'; | |
describe("Hash - Guid", () => { | |
it ('should output a string value', () => { | |
let g = guid(); | |
expect(g).toEqual(jasmine.any(String)); | |
}); | |
}); | |
// Based on the tests for @valkyriestudios/utils (github.com/valkyriestudios/utils) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(config) { | |
config.set({ | |
basePath: './', | |
frameworks: ['jasmine'], | |
files: [ | |
{pattern: 'test/test_index.js'}, | |
], | |
exclude: [], | |
preprocessors: { | |
'test/test_index.js': ['webpack'], | |
}, | |
webpack: { | |
mode: 'development', | |
}, | |
webpackMiddleware: { | |
noInfo: true, | |
stats: { | |
chunks: false, | |
}, | |
}, | |
reporters: ['progress'], | |
port: 9876, | |
colors: true, | |
logLevel: config.LOG_INFO, | |
autoWatch: true, | |
browsers: ['ChromeHeadless'], | |
singleRun: false, | |
customLaunchers: { | |
ChromeHeadless: { | |
base: 'Chrome', | |
flags: [ | |
'--no-sandbox', | |
'--headless', | |
'--disable-gpu', | |
'--remote-debugging-port=9222', | |
], | |
}, | |
}, | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"test": "karma start karma.conf.js", | |
}, | |
"devDependencies": { | |
"babel-core": "^6.26.3", | |
"babel-loader": "^7.1.5", | |
"babel-preset-env": "^1.7.0", | |
"jasmine-core": "^3.1.0", | |
"karma": "^2.0.5", | |
"karma-chrome-launcher": "^2.2.0", | |
"karma-jasmine": "^1.1.2", | |
"karma-webpack": "^3.0.0", | |
"puppeteer": "^1.6.1", | |
"webpack": "^4.16.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var testsContext = require.context(".", true, /\.test\.js$/); | |
testsContext.keys().forEach(testsContext); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment