Skip to content

Commit

Permalink
test: Add node test environment (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 authored Sep 29, 2023
1 parent 6fc2070 commit c7fa496
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 14 deletions.
26 changes: 13 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
"scripts": {
"testKarma": "node test/boilerplate/test-karma.js",
"build": "rollup --config rollup.config.js",
"build:test": "ENVIRONMENT=production rollup --config rollup.test.config.js",
"watch": "rollup --config rollup.config.js -w",
"test": "npm run build && npm run build:test && DEBUG=false karma start test/karma.config.js",
"test:debug": "npm run build && npm run build:test && DEBUG=true karma start test/karma.config.js",
"testEndToEnd": "browserify node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/index.js -v -o test/end-to-end-testapp/build/compilation.js && open http://localhost:8082/node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/index.html && node node_modules/@mparticle/web-kit-wrapper/end-to-end-testapp/server"
},
"devDependencies": {
"@mparticle/web-sdk": "^2.11.1",
"@mparticle/web-sdk": "^2.23.4",
"chai": "^4.2.0",
"karma": "^5.1.0",
"karma-chai": "^0.1.0",
Expand Down
14 changes: 14 additions & 0 deletions rollup.test.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { ENVIRONMENT } = process.env;

import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
input: 'test/tests.js',
output: {
file: 'test/test-bundle.js',
format: 'iife',
name: 'mParticleTests',
},
plugins: [resolve(), commonjs()],
};
3 changes: 3 additions & 0 deletions test/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
window.mParticle.addForwarder = function(forwarder) {
window.mParticle.forwarder = new forwarder.constructor();
};
39 changes: 39 additions & 0 deletions test/karma.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { DEBUG } = process.env || 'false';

const files = [
'../node_modules/@mparticle/web-sdk/dist/mparticle.js',
'../node_modules/mocha/mocha.js',
'../node_modules/should/should.js',
'config.js',
'../dist/DoubleClick-Kit.iife.js',
'lib/mockhttprequest.js',
'./test-bundle.js',
];

let browsers = ['ChromeHeadless', 'FirefoxHeadless'];
let singleRun = true;

if (DEBUG === 'true') {
browsers = ['Chrome'];
singleRun = false;
}

module.exports = function(config) {
config.set({
frameworks: ['mocha', 'chai'],
files,
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers,
concurrency: Infinity,
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: ['-headless'],
},
},
singleRun,
});
};

0 comments on commit c7fa496

Please sign in to comment.