Skip to content

Commit

Permalink
ci: POC - Add BrowserStack config files (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 committed Oct 24, 2023
1 parent 6b9f602 commit b63610b
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 26 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"build:rollup:requirejs": "rollup --config test/integrations/requirejs/rollup.requirejs.config.js",
"build:ts": "tsc -p .",
"test": "npm run build && npm run build:test-bundle && cross-env DEBUG=false karma start test/karma.config.js",
"test:browserstack": "karma start test/cross-browser-testing/browserstack/browserstack.karma.config.js",
"test:browserstack:debug": "cross-env DEBUG=true karma start test/cross-browser-testing/browserstack/browserstack.karma.config.js",
"test:debug": "cross-env DEBUG=true karma start test/karma.config.js",
"test:stub": "cross-env TESTTYPE=stub ENVIRONMENT=prod rollup --config rollup.test.config.js && karma start test/stub/karma.stub.config.js",
"test:integrations": "npm run test:requirejs && npm run test:integrations:cjs && npm run test:integrations:module",
Expand Down Expand Up @@ -111,6 +113,7 @@
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"karma": "^6.3.2",
"karma-browserstack-launcher": "^1.6.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-edge-launcher": "^0.4.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const { DEBUG } = process.env;

const files = [
'../../lib/mockhttprequest.js',
'../../lib/geomock.js',
'../../../node_modules/fetch-mock/dist/es5/client-bundle.js',
'../../../node_modules/sinon-browser-only/sinon.js',
'../../config.js',
'../../../dist/mparticle.js',
'../../test-bundle.js'
];

const singleRun = true;

let captureConsole = false;
let browserConsoleLogOptions = {};

// Allows console logs to appear when doing npm run test:debug
if (DEBUG === 'true') {
browserConsoleLogOptions = {
level: 'log',
format: '%b %T: %m',
terminal: true,
};
captureConsole = true;
} else {
browserConsoleLogOptions = {
terminal: false,
};
}

module.exports = function(config) {
config.set({
browserStack: {
username: process.env.BS_USERNAME,
accessKey: process.env.BS_ACCESS_KEY
},
// define browsers
customLaunchers: {
// Firefox 21 fails non-es6 tests
bs_firefox_mac_21: {
base: 'BrowserStack',
browser: 'firefox',
browser_version: '21.0',
os: 'OS X',
os_version: 'Snow Leopard'
},
bs_firefox_mac_100: {
base: 'BrowserStack',
browser: 'firefox',
browser_version: '100.0',
os: 'OS X',
os_version: 'Ventura'
}
},
browsers: ['bs_firefox_mac_21', 'bs_firefox_mac_100'],
frameworks: ['mocha', 'should'],
files,
reporters: ['progress', 'junit'],
colors: true,
concurrency: Infinity,
singleRun,
debug: true,
logLevel: config.LOG_INFO,
browserConsoleLogOptions,
client: {
captureConsole,
},
junitReporter: {
outputDir: 'reports/',
outputFile: 'test-karma.xml',
},
});
};
8 changes: 8 additions & 0 deletions test/cross-browser-testing/test-cross-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('test browserstack integration', function() {
it('should pass', function() {
true.should.equal(true);
});
it('should not pass on older browsers', function() {
'foo-bar'.replaceAll('o', 0).should.equal('f00-bar');
});
});
52 changes: 26 additions & 26 deletions test/src/tests-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ beforeEach(function() {
});

import './tests-core-sdk';
import './tests-batchUploader';
import './tests-beaconUpload';
import './tests-kit-blocking';
import './tests-persistence';
import './tests-forwarders';
import './tests-helpers';
import './tests-identity';
import './tests-event-logging';
import './tests-eCommerce';
import './tests-cookie-syncing';
import './tests-identities-attributes';
import './tests-native-sdk';
import './tests-consent';
import './tests-serverModel';
import './tests-mockBatchCreator.ts';
import './tests-mParticleUser';
import './tests-self-hosting-specific';
import './tests-runtimeToBatchEventsDTO';
import './tests-apiClient';
import './tests-mparticle-instance-manager';
import './tests-queue-public-methods';
import './tests-validators';
import './tests-utils';
import './tests-session-manager';
import './tests-store';
import './tests-config-api-client';
// import './tests-batchUploader';
// import './tests-beaconUpload';
// import './tests-kit-blocking';
// import './tests-persistence';
// import './tests-forwarders';
// import './tests-helpers';
// import './tests-identity';
// import './tests-event-logging';
// import './tests-eCommerce';
// import './tests-cookie-syncing';
// import './tests-identities-attributes';
// import './tests-native-sdk';
// import './tests-consent';
// import './tests-serverModel';
// import './tests-mockBatchCreator.ts';
// import './tests-mParticleUser';
// import './tests-self-hosting-specific';
// import './tests-runtimeToBatchEventsDTO';
// import './tests-apiClient';
// import './tests-mparticle-instance-manager';
// import './tests-queue-public-methods';
// import './tests-validators';
// import './tests-utils';
// import './tests-session-manager';
// import './tests-store';
// import './tests-config-api-client';

0 comments on commit b63610b

Please sign in to comment.