Skip to content

Commit

Permalink
Merge pull request #18 from dotcore64/chore/karma-node-resolve-prepro…
Browse files Browse the repository at this point in the history
…cessor

Use karma-node-resolve-preprocessor for testing
  • Loading branch information
perrin4869 authored Jun 13, 2022
2 parents f7c0143 + e70d10c commit 092b51e
Show file tree
Hide file tree
Showing 3 changed files with 704 additions and 2,104 deletions.
8 changes: 6 additions & 2 deletions karma.conf.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ module.exports = (config) => {
// list of files / patterns to load in the browser
files: [
{ pattern: 'test/index.js', type: 'module' },
{ pattern: 'index.js', type: 'module', included: false },
{ pattern: 'node_modules/**/*.js', type: 'module', included: false },
],

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/*.js': ['rollup', 'sourcemap'],
'test/*.js': ['rollup', 'node-resolve', 'sourcemap'],
'index.js': ['coverage', 'node-resolve'],
'node_modules/@(is-ip|ip-regex)/**/*.js': ['node-resolve'],
},

// test results reporter to use
Expand Down Expand Up @@ -56,8 +60,8 @@ module.exports = (config) => {
concurrency: Number.POSITIVE_INFINITY,

rollupPreprocessor: {
external: 'chai-ip',
plugins: [
require('rollup-plugin-istanbul')({ exclude: ['**/test/**', 'node_modules/**'] }), // eslint-disable-line global-require
require('@rollup/plugin-node-resolve').default({ // eslint-disable-line global-require
mainFields: ['module', 'browser', 'main'],
}),
Expand Down
Loading

0 comments on commit 092b51e

Please sign in to comment.