Skip to content

Commit

Permalink
Setup BigTest infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Wilsman committed Oct 3, 2018
1 parent 89de181 commit de7fc4d
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .stripesclirc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const webpack = require('webpack');

const miragePlugin = {
// Standard yargs options object
options: {
'mirage [scenario]': {
describe: 'Enable Mirage Server and specify a scenario',
type: 'string',
group: 'Mirage Server'
},
},

// Stripes CLI hook into "webpackOverrides"
beforeBuild: (options) => {
const mirageOption = options.mirage === true ? 'default' : options.mirage;

return (config) => {
config.plugins.push(new webpack.EnvironmentPlugin({
MIRAGE_SCENARIO: mirageOption || 'default'
}));

if (!!mirageOption) {
console.info('Using Mirage Server'); // eslint-disable-line no-console

return Object.assign({}, config, {
entry: ['./tests/network/boot'].concat(config.entry)
});
} else {
return config;
}
};
}
}

module.exports = {
hasAllPerms: true,

aliases: {
'@folio/stripes-smart-components': '.'
},

// Custom command extension
plugins: {
serve: miragePlugin
}
};
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"node": ">=6.0.0"
},
"stripes": {
"type": "components",
"okapiInterfaces": {
"notes": "1.0",
"tags": "1.0"
Expand Down Expand Up @@ -76,16 +75,26 @@
"lint": "eslint . && stylelint \"lib/**/*.css\"",
"eslint": "eslint .",
"stylelint": "stylelint \"lib/**/*.css\"",
"test": "echo 'placeholder. no tests implemented'"
"test": "stripes test karma"
},
"devDependencies": {
"@bigtest/convergence": "^1.0.0",
"@bigtest/interactor": "^0.7.2",
"@bigtest/mirage": "^0.0.1",
"@bigtest/mocha": "^0.5.1",
"@bigtest/react": "^0.1.2",
"@folio/eslint-config-stripes": "^3.2.1",
"@folio/stripes-cli": "^1.5.0",
"@folio/stripes-core": "^2.14.0",
"babel-eslint": "^9.0.0",
"chai": "^4.2.0",
"eslint": "^5.5.0",
"mocha": "^5.2.0",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"sinon": "^6.3.4",
"stylelint": "^9.5.0",
"stylelint-config-standard": "^18.2.0"
},
Expand Down
9 changes: 9 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require('babel-polyfill');

// require all test files matching 'lib/**/tests/*-test'
const requireTest = require.context('../lib/', true, /(.*?)\/tests\/(.*?)-test/);
requireTest.keys().forEach(requireTest);

// require all source files in lib for code coverage
const componentsContext = require.context('../lib/', true, /^(?!.*(stories|examples)).*\.js$/);
componentsContext.keys().forEach(componentsContext);
9 changes: 9 additions & 0 deletions tests/network/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import startMirage from '@folio/stripes-core/test/bigtest/network/start';
import mirageOptions from '.';

/**
* Start mirage to handle requests in development and production. Note
* that this file will _not_ be include in the build at all if mirage
* is disabled. Also, it will not included in test builds.
*/
window.mirage = startMirage(process.env.MIRAGE_SCENARIO, mirageOptions);
3 changes: 3 additions & 0 deletions tests/network/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// typical mirage config export
export default function configure() {
}
Empty file.
Empty file added tests/network/fixtures/.gitkeep
Empty file.
28 changes: 28 additions & 0 deletions tests/network/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { camelize } from '@bigtest/mirage';

// auto-import all mirage submodules
const req = require.context('./', true, /\.js$/);
const modules = req.keys().reduce((acc, modulePath) => {
const moduleParts = modulePath.split('/');
const moduleType = moduleParts[1];
const moduleName = moduleParts[2];

if (moduleName) {
const moduleKey = camelize(moduleName.replace('.js', ''));

return Object.assign(acc, {
[moduleType]: {
...(acc[moduleType] || {}),
[moduleKey]: req(modulePath).default
}
});
} else if (modulePath === './config.js') {
return Object.assign(acc, {
baseConfig: req(modulePath).default
});
} else {
return acc;
}
}, {});

export default modules;
Empty file added tests/network/models/.gitkeep
Empty file.
Empty file.
Empty file.

0 comments on commit de7fc4d

Please sign in to comment.