Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@codeceptjs/configure

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codeceptjs/configure - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0

hooks/setTestHost.js

5

CHANGELOG.md

@@ -0,1 +1,6 @@

0.7.0
* Added `setTestHost` hook
* Added support for firefox for WebDriver in `setHeadlessWhen` hook
0.6.0

@@ -2,0 +7,0 @@

25

hooks/setHeadedWhen.js

@@ -8,3 +8,3 @@ const { config } = require('../codeceptjs');

if (!cfg.helpers) return;
if (cfg.helpers.Puppeteer) {
if (cfg.helpers.Puppeteer) {
cfg.helpers.Puppeteer.show = true;

@@ -14,3 +14,3 @@ }

cfg.helpers.Playwright.show = true;
}
}
if (cfg.helpers.Nightmare) {

@@ -25,3 +25,3 @@ cfg.helpers.Nightmare.show = true;

if (
cfg.helpers.WebDriver.desiredCapabilities &&
cfg.helpers.WebDriver.desiredCapabilities &&
cfg.helpers.WebDriver.desiredCapabilities.chromeOptions &&

@@ -34,3 +34,3 @@ cfg.helpers.WebDriver.desiredCapabilities.chromeOptions.args

if (
cfg.helpers.WebDriver.capabilities &&
cfg.helpers.WebDriver.capabilities &&
cfg.helpers.WebDriver.capabilities.chromeOptions &&

@@ -42,2 +42,19 @@ cfg.helpers.WebDriver.capabilities.chromeOptions.args

}
} else if (cfg.helpers.WebDriver.browser === 'firefox') {
if (
cfg.helpers.WebDriver.desiredCapabilities &&
cfg.helpers.WebDriver.desiredCapabilities.firefoxOptions &&
cfg.helpers.WebDriver.desiredCapabilities.firefoxOptions.args
) {
const args = cfg.helpers.WebDriver.desiredCapabilities.firefoxOptions.args;
cfg.helpers.WebDriver.desiredCapabilities.firefoxOptions.args = args.filter(key => key !== '--headless')
}
if (
cfg.helpers.WebDriver.capabilities &&
cfg.helpers.WebDriver.capabilities.firefoxOptions &&
cfg.helpers.WebDriver.capabilities.firefoxOptions.args
) {
const args = cfg.helpers.WebDriver.capabilities.firefoxOptions.args;
cfg.helpers.WebDriver.capabilities.firefoxOptions.args = args.filter(key => key !== '--headless')
}

@@ -44,0 +61,0 @@ }

@@ -14,3 +14,3 @@ const { config } = require('../codeceptjs');

cfg.helpers.Playwright.show = false;
}
}
if (cfg.helpers.Nightmare) {

@@ -29,3 +29,3 @@ cfg.helpers.Nightmare.show = false;

chromeOptions: {
args: [
args: [
"--headless",

@@ -39,2 +39,13 @@ // Use --disable-gpu to avoid an error from a missing Mesa library, as per

)
} else if (cfg.helpers.WebDriver.browser === 'firefox') {
cfg.helpers.WebDriver.desiredCapabilities = merge(
cfg.helpers.WebDriver.desiredCapabilities || {},
{
firefoxOptions: {
args: [
"--headless",
]
}
}
)
}

@@ -41,0 +52,0 @@ }

2

hooks/setSharedCookies.js
const { container, config, event, output } = require('../codeceptjs');
module.exports = function() {
const browserHelpers = ['WebDriver','Protractor','Playwright','Puppeteer','TestCafe','Nigthmare'];
const browserHelpers = ['WebDriver','Protractor','Playwright','Puppeteer','TestCafe','Nightmare'];
config.addHook(cfg => {

@@ -6,0 +6,0 @@ const helper = detectBrowserHelper(cfg.helpers);

@@ -7,2 +7,3 @@ module.exports = {

setBrowser: require('./hooks/setBrowser'),
setTestHost: require('./hooks/setTestHost'),
}
{
"name": "@codeceptjs/configure",
"version": "0.6.2",
"version": "0.7.0",
"description": "Set of CodeceptJS config hooks to simplify configuration",

@@ -31,3 +31,3 @@ "main": "index.js",

"codeceptjs": "^3.0.0",
"mocha": "^6.2.0",
"mocha": "^8.2.1",
"puppeteer": "^2.1",

@@ -34,0 +34,0 @@ "webdriverio": "^6.4.2"

@@ -48,3 +48,3 @@ ## CodeceptJS Configuration Hooks [![Build Status](https://travis-ci.org/codeceptjs/configure.svg?branch=master)](https://travis-ci.org/codeceptjs/configure)

* For Puppeteer, TestCafe, Nigthmare, Playwright: it enables `show: true`.
* For WebDriver with Chrome browser: it adds `--headless` option to chrome options inside `desiredCapabilities`.
* For WebDriver with Chrome or Firefox browser: it adds `--headless` option to chrome/firefox options inside `desiredCapabilities`.

@@ -84,3 +84,3 @@ ### setHeadedWhen

// standard config goes here
}
},
// or Puppeteer

@@ -130,2 +130,12 @@ // or TestCafe,

### setTestHost
Changes url in config for Playwright, Puppeteer, WebDriver, Protractor & TestCafe:
```js
const { setTestHost } = require('@codeceptjs/configure');
setTestHost(process.env.TEST_HOST);
```
## Contributing

@@ -132,0 +142,0 @@

const Config = require('../codeceptjs').config;
const { expect } = require('chai');
const {
setHeadlessWhen,
setHeadedWhen,
const {
setHeadlessWhen,
setHeadedWhen,
setSharedCookies,
setWindowSize,
setBrowser,
setTestHost,
} = require('../index');

@@ -24,3 +25,3 @@

},
},
},
}

@@ -30,3 +31,3 @@ setHeadlessWhen(false);

expect(Config.get()).to.have.nested.property('helpers.Puppeteer.show', true);
});
});
it('should enable headless for Puppeteer', () => {

@@ -41,3 +42,3 @@ const config = {

},
},
},
}

@@ -58,3 +59,3 @@ setHeadlessWhen(true);

},
},
},
}

@@ -67,3 +68,3 @@ setHeadlessWhen(true);

it('should enable headless for WebDriver', () => {
it('should enable headless for WebDriver with browser Chrome', () => {
const config = {

@@ -77,3 +78,3 @@ helpers: {

},
},
},
}

@@ -85,2 +86,18 @@ setHeadlessWhen(true);

it('should enable headless for WebDriver with browser Firefox', () => {
const config = {
helpers: {
WebDriver: {
url: 'http://localhost',
browser: 'firefox',
restart: false,
windowSize: '1600x1200',
},
},
}
setHeadlessWhen(true);
Config.create(config);
expect(Config.get()).to.have.nested.property('helpers.WebDriver.desiredCapabilities.firefoxOptions.args[0]', '--headless');
});
});

@@ -96,3 +113,3 @@

},
},
},
}

@@ -102,3 +119,3 @@ setHeadedWhen(false);

expect(Config.get()).to.have.nested.property('helpers.Puppeteer.show', true);
});
});
it('should enable Headed for Puppeteer', () => {

@@ -113,3 +130,3 @@ const config = {

},
},
},
}

@@ -130,3 +147,3 @@ setHeadedWhen(true);

},
},
},
}

@@ -136,5 +153,5 @@ setHeadedWhen(true);

expect(Config.get()).to.have.nested.property('helpers.Playwright.show', true);
});
});
it('should enable Headed for WebDriver', () => {
it('should enable Headed for WebDriver with browser Chrome', () => {
const config = {

@@ -153,3 +170,3 @@ helpers: {

},
},
},
}

@@ -161,4 +178,25 @@ setHeadedWhen(true);

});
it('should enable Headed for WebDriver with browser Firefox', () => {
const config = {
helpers: {
WebDriver: {
url: 'http://localhost',
browser: 'firefox',
restart: false,
windowSize: '1600x1200',
desiredCapabilities: {
firefoxOptions: {
args: ['--headless']
}
}
},
},
}
setHeadedWhen(true);
Config.create(config);
expect(Config.get()).not.to.have.nested.property('helpers.WebDriver.desiredCapabilities.firefoxOptions.args[0]', '--headless');
});
});
describe('#setSharedCookies', () => {

@@ -179,3 +217,3 @@ const fn = async (request) => {

REST: {}
},
},
}

@@ -194,3 +232,3 @@ setSharedCookies(true);

GraphQLDataFactory: {}
},
},
}

@@ -203,3 +241,3 @@ setSharedCookies(true);

expect(Config.get().helpers.GraphQLDataFactory.onRequest.toString()).to.eql(fn.toString())
});
});
});

@@ -212,3 +250,3 @@

const config = {
helpers: {},
helpers: {},
}

@@ -225,3 +263,3 @@ config.helpers[helper] = {};

const config = {
helpers: {
helpers: {
Puppeteer: {

@@ -247,3 +285,3 @@ chrome: {

const config = {
helpers: {},
helpers: {},
}

@@ -265,3 +303,3 @@ config.helpers[helper] = {};

}
},
},
}

@@ -278,3 +316,18 @@ setBrowser('chrome');

});
describe('#setTestHost', () => {
['Protractor', 'TestCafe','WebDriver','Playwright','Puppeteer'].forEach(helper => {
it('should set url for ' + helper, () => {
Config.reset();
const config = {
helpers: {},
}
config.helpers[helper] = {};
setTestHost('test.com');
Config.create(config);
expect(Config.get()).to.have.nested.property(`helpers.${helper}.url`);
expect(Config.get().helpers[helper].url).to.eql('test.com');
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc