Add: Karma
This commit is contained in:
@@ -9,3 +9,4 @@
|
||||
.gitignore
|
||||
.npmignore
|
||||
.travis.yml
|
||||
karma.conf.js
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "6"
|
||||
- "7"
|
||||
before_script:
|
||||
- npm install -g webpack
|
||||
- npm install -g eslint
|
||||
- npm install -g karma-cli
|
||||
script:
|
||||
- bash script/ci.sh
|
||||
- npm run lint
|
||||
- npm run build
|
||||
- npm run test
|
||||
|
||||
44
karma.conf.js
Normal file
44
karma.conf.js
Normal file
@@ -0,0 +1,44 @@
|
||||
module.exports = function (config)
|
||||
{
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jquery-1.8.3'],
|
||||
files: [
|
||||
'eruda.js',
|
||||
'test/init.js',
|
||||
'node_modules/jasmine-core/lib/jasmine-core/jasmine.js',
|
||||
'node_modules/karma-jasmine/lib/boot.js',
|
||||
'node_modules/karma-jasmine/lib/adapter.js',
|
||||
'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
|
||||
'test/console.js',
|
||||
'test/elements.js',
|
||||
'test/features.js',
|
||||
'test/info.js',
|
||||
'test/network.js',
|
||||
'test/resources.js',
|
||||
'test/snippets.js',
|
||||
'test/sources.js',
|
||||
// 'test/settings.js'
|
||||
],
|
||||
plugins: [
|
||||
'karma-jasmine',
|
||||
'karma-jquery',
|
||||
'karma-phantomjs-launcher',
|
||||
'karma-wrap-preprocessor'
|
||||
],
|
||||
preprocessors: {
|
||||
'test/*.js': ['wrap']
|
||||
},
|
||||
wrapPreprocessor: {
|
||||
template: '(function () { <%= contents %> })()'
|
||||
},
|
||||
reporters: ['progress'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
browsers: ['PhantomJS'],
|
||||
singleRun: true,
|
||||
concurrency: Infinity
|
||||
});
|
||||
};
|
||||
10
package.json
10
package.json
@@ -6,6 +6,7 @@
|
||||
"scripts": {
|
||||
"build": "webpack --config script/webpack.dev.js && webpack -p --config script/webpack.release.js",
|
||||
"dev": "webpack-dev-server --config script/webpack.dev.js --host 0.0.0.0",
|
||||
"test": "karma start",
|
||||
"cpTestLib": "script/cpTestLib.sh",
|
||||
"lint": "eslint --ext .es6 src",
|
||||
"utilDoc": "eustia doc src/lib/util.js -f md -o doc/UTIL_API.md -t \"Eruda Util Documentation\""
|
||||
@@ -14,7 +15,9 @@
|
||||
"files": "src/**/*.es6",
|
||||
"ignore": "**/Info/defInfo.es6",
|
||||
"output": "src/lib/util.js",
|
||||
"exclude": ["createCfg"],
|
||||
"exclude": [
|
||||
"createCfg"
|
||||
],
|
||||
"format": "commonjs"
|
||||
},
|
||||
"repository": {
|
||||
@@ -47,6 +50,11 @@
|
||||
"jquery": "^3.1.0",
|
||||
"js-beautify": "^1.6.2",
|
||||
"json-loader": "^0.5.4",
|
||||
"karma": "^1.7.0",
|
||||
"karma-jasmine": "^1.1.0",
|
||||
"karma-jquery": "^0.2.2",
|
||||
"karma-phantomjs-launcher": "^1.0.4",
|
||||
"karma-wrap-preprocessor": "^0.1.0",
|
||||
"modernizr": "^3.3.1",
|
||||
"node-sass": "^4.5.0",
|
||||
"postcss-class-prefix": "^0.3.0",
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
npm run lint
|
||||
npm run build
|
||||
@@ -242,7 +242,7 @@ var regJsUrl = /https?:\/\/([0-9.\-A-Za-z]+)(?::(\d+))?\/[A-Z.a-z0-9/]*\.js/g,
|
||||
|
||||
function formatErr(err)
|
||||
{
|
||||
var lines = err.stack.split('\n'),
|
||||
var lines = err.stack ? err.stack.split('\n') : [],
|
||||
msg = `${err.message || lines[0]}<br/>`;
|
||||
|
||||
lines = lines.filter(val => !regErudaJs.test(val))
|
||||
@@ -383,7 +383,7 @@ function getFrom()
|
||||
{
|
||||
let e = new Error(),
|
||||
ret = '',
|
||||
lines = e.stack.split('\n');
|
||||
lines = e.stack ? e.stack.split('\n') : '';
|
||||
|
||||
for (let i = 0, len = lines.length; i < len; i++)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@ beforeEach(function ()
|
||||
|
||||
describe('log', function ()
|
||||
{
|
||||
|
||||
it('string', function ()
|
||||
{
|
||||
var text = '<span>This is a log</span>';
|
||||
@@ -36,12 +35,6 @@ describe('log', function ()
|
||||
expect($tool.find('.eruda-log')).toContainText('Object { a: 1 }');
|
||||
});
|
||||
|
||||
it('dir html element', function ()
|
||||
{
|
||||
tool.dir(document.createElement('script'));
|
||||
expect($tool.find('.eruda-log')).not.toContainText('<script></script>');
|
||||
});
|
||||
|
||||
it('html', function ()
|
||||
{
|
||||
tool.html('<span class="color-blue">Blue</span>');
|
||||
|
||||
1
test/init.js
Normal file
1
test/init.js
Normal file
@@ -0,0 +1 @@
|
||||
eruda.init();
|
||||
Reference in New Issue
Block a user