Skip to content

Instantly share code, notes, and snippets.

@peterver
Created July 29, 2018 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterver/42c32e66e03d3d3a609b19b1ecc4b50f to your computer and use it in GitHub Desktop.
Save peterver/42c32e66e03d3d3a609b19b1ecc4b50f to your computer and use it in GitHub Desktop.
Karma Setup with Chrome Headless + Jasmine + Webpack
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)
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',
],
},
},
});
};
{
"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"
}
}
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