MCPcopy
hub / github.com/web-push-libs/web-push / runTest

Function runTest

test/testSelenium.js:33–173  ·  view source on GitHub ↗
(browser, options)

Source from the content-addressed store, hash-verified

31let testServerURL;
32
33function runTest(browser, options) {
34 options = options || {};
35
36 if (process.env.CI) {
37 return Promise.resolve();
38 }
39
40 return createServer(options, webPush)
41 .then(function(server) {
42 globalServer = server;
43 testServerURL = 'http://127.0.0.1:' + server.port;
44
45 if (browser.getId() === 'firefox') {
46 // This is based off of: https://bugzilla.mozilla.org/show_bug.cgi?id=1275521
47 // Unfortunately it doesn't seem to work :(
48 const ffProfile = new seleniumFirefox.Profile();
49 ffProfile.setPreference('dom.push.testing.ignorePermission', true);
50 ffProfile.setPreference('notification.prompt.testing', true);
51 ffProfile.setPreference('notification.prompt.testing.allow', true);
52 browser.getSeleniumOptions().setProfile(ffProfile);
53 } else if (browser.getId() === 'chrome') {
54 const chromeOperaPreferences = {
55 profile: {
56 content_settings: {
57 exceptions: {
58 notifications: {}
59 }
60 }
61 }
62 };
63 chromeOperaPreferences.profile.content_settings.exceptions.notifications[testServerURL + ',*'] = {
64 setting: 1
65 };
66 /* eslint-enable camelcase */
67
68 // Write to a file
69 const tempPreferenceDir = './test/output/temp/chromeOperaPreferences';
70 mkdirp.sync(tempPreferenceDir + '/Default');
71
72 // NOTE: The Default part of this path might be Chrome specific.
73 fs.writeFileSync(tempPreferenceDir + '/Default/Preferences', JSON.stringify(chromeOperaPreferences));
74
75 const seleniumOptions = browser.getSeleniumOptions();
76 seleniumOptions.addArguments('user-data-dir=' + tempPreferenceDir + '/');
77 }
78
79 return browser.getSeleniumDriver();
80 })
81 .then(function(driver) {
82 globalDriver = driver;
83
84 if (options.vapid) {
85 testServerURL += '?vapid=' + options.vapid.publicKey;
86 }
87
88 return globalDriver.get(testServerURL)
89 .then(function() {
90 return globalDriver.executeScript(function() {

Callers 1

testSelenium.jsFile · 0.85

Calls 1

createServerFunction · 0.85

Tested by

no test coverage detected