-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished architecture, working on writing unit tests
- Loading branch information
1 parent
15ff870
commit d1b70b8
Showing
8 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
lib/ | ||
coverage/ | ||
npm-debug.log |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
language: node_js | ||
node_js: | ||
- '4' | ||
addons: | ||
apt: | ||
packages: | ||
- xvfb | ||
before_script: | ||
- export DISPLAY=:99.0 | ||
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | ||
- npm test | ||
install: | ||
- export DISPLAY=':99.0' | ||
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | ||
- npm install | ||
- '6' | ||
script: | ||
- npm lint | ||
- npm run test:lcov | ||
after_success: | ||
- if [[ $TRAVIS_BRANCH" == "master" ]] ; then cat ./coverage/lcov.info | node_modules/.bin/coveralls --verbose; fi | ||
- rm -rf ./coverage |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
const path = require('path'); | ||
// Require webpack config rather than duplicating it | ||
const webpackConfig = require('./webpack.config'); | ||
|
||
const args = process.argv.slice(2); | ||
const isCoverage = args.indexOf('-coverage') !== -1; | ||
const isLcov = args.indexOf('-lcov') !== -1; | ||
|
||
module.exports = function karmaConfig(config) { | ||
config.set({ | ||
// ... normal karma configuration | ||
browsers: ['PhantomJS'], | ||
singleRun: true, | ||
files: [ | ||
// 'node_modules/babel-polyfill/dist/polyfill.js', | ||
'test/index.js' | ||
// each file acts as entry point for the webpack configuration | ||
], | ||
preprocessors: { | ||
// add webpack as preprocessor | ||
'test/index.js': ['webpack', 'sourcemap'] | ||
}, | ||
plugins: ['karma-webpack', 'karma-jasmine', 'karma-nyan-reporter', 'karma-coverage', 'karma-sourcemap-loader', 'karma-phantomjs-launcher', 'karma-phantomjs-shim'], | ||
frameworks: ['phantomjs-shim', 'jasmine'], | ||
reporters: [isLcov ? 'dots' : 'nyan'].concat(isCoverage ? ['coverage'] : []), | ||
// reporter options | ||
nyanReporter: { | ||
suppressErrorHighlighting: true | ||
}, | ||
coverageReporter: { | ||
dir: 'coverage/', | ||
reporters: [{ | ||
type: isLcov ? 'lcov' : 'html', // lcov or lcovonly are required for generating lcov.info files, html for local coverage report | ||
subdir: '.' | ||
}] | ||
}, | ||
webpack: Object.assign(webpackConfig, { | ||
entry: undefined, | ||
output: undefined, | ||
devtool: 'inline-source-map', | ||
// *optional* isparta options: istanbul behind isparta will use it | ||
isparta: { | ||
embedSource: true, | ||
noAutoWrap: true, | ||
// these babel options will be passed only to isparta and not to babel-loader | ||
babel: { | ||
presets: ['es2015'] | ||
} | ||
}, | ||
// Override `module` in `webpackConfig` only if coverage is produced | ||
module: Object.assign(webpackConfig.module, isCoverage ? { | ||
preLoaders: webpackConfig.module.preLoaders.concat([ | ||
{ // `isparta` all the code We want to be in the coverage report | ||
test: /\.js$/, | ||
include: [ | ||
path.resolve('src/') | ||
], | ||
loader: 'isparta' | ||
}, { | ||
// Addig js loader to preloader, with all the code we don't want in the coverage report which `isparta` doesn't coverage | ||
// Using `include` property to add those directories | ||
test: /\.js$/, | ||
include: [ | ||
path.resolve('test/') | ||
], | ||
loader: 'babel?presets[]=es2015' | ||
} | ||
]), | ||
// Exclude js loaders from `loaders` because they are set in preLoaders | ||
loaders: webpackConfig.module.loaders.filter(loaderObj => (typeof loaderObj.test !== 'function' && loaderObj.test.toString().indexOf('.js') === -1)) | ||
} : {}) | ||
}), | ||
webpackMiddleware: { | ||
noInfo: true | ||
} | ||
}); | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"env": { | ||
"node": false, | ||
"jasmine": true | ||
}, | ||
"ecmaFeatures": { | ||
"modules": true | ||
}, | ||
"rules": { | ||
"strict": [2, "never"], | ||
"no-console": 2 | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// load all specs into one bundle | ||
const testsContext = require.context('.', true, /-spec\.js$/); | ||
testsContext.keys().forEach(testsContext); | ||
|
||
// require all `src/**/*.js` | ||
const componentsContext = require.context('../src/', true, /\.js$/); | ||
componentsContext.keys().forEach(componentsContext); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import createPanelInjector from 'inject!src/create-panel'; | ||
it('', () => { | ||
expect(1).toBe(1); | ||
}); |
This file contains 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