Skip to content

Commit

Permalink
fix: update dependencies and cypress configuration (#7)
Browse files Browse the repository at this point in the history
* fix: update loader to use cypress extension loading capabilities
* build: remove package-lock.json from ignored files
* chore: update cypress version to latest cypress still using json config files
* ci: update cypress to v10
* test: disable video and screenshots on tests
* style: rename second plugin hook argument
* fix: remove unnecessary loop on extension loader
* fix: change browser. to chrome. for tests on chrome
* chore: add cypress open script to package.json
* build: update dependencies via ncu
* fix: downgrade nanoid to last version not using esm
* fix: remove extra debug log and ficxx find/replace errors
  • Loading branch information
victal authored Feb 15, 2023
1 parent 3b22ec3 commit 396efe8
Show file tree
Hide file tree
Showing 12 changed files with 3,212 additions and 3,345 deletions.
13 changes: 13 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
video: false,
screenshotOnRunFailure: false,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
},
})
1 change: 0 additions & 1 deletion cypress.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const extensionLoader = require('../../loader.js');
const path = require('path');

module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => (
on('before:browser:launch', (browser = {}, launchOptions) => (
extensionLoader.load(
path.join(config.fixturesFolder, 'unpacked'), {
source: path.join(config.fixturesFolder, 'unpacked'),
Expand All @@ -18,6 +18,6 @@ module.exports = (on, config) => {
source: path.join(config.fixturesFolder, 'crxpacked.crx'),
alias: 'crxpacked',
},
)(browser, args)
)(browser, launchOptions)
));
};
File renamed without changes.
2 changes: 1 addition & 1 deletion helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const nanoid = require('nanoid');
const { nanoid } = require('nanoid');

const common = require('./lib/common');

Expand Down
22 changes: 4 additions & 18 deletions loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const hookFilesDir = 'cypress-extension-hooks';

const defaultOptions = {
alias: defaultAlias,
validBrowsers: ['chrome'],
skipHooks: false,
cypressMatches: ['*://*/*/integration/*'],
watch: true,
Expand Down Expand Up @@ -145,29 +144,16 @@ const whenAllBuilt = () => Promise.all(buildPromises);

// for use in the on('before:browser:launch') Cypress hook
// returns a promise resolving to the browser args once all the tempextensions are built
function onBeforeBrowserLaunch(browser = {}, config) {

// In Cypress v3, second argument is `args` array
// In Cypress v4, second argument is `launchOptions` object with `args` array in it
const args = Array.isArray(config) ? config : config.args

function onBeforeBrowserLaunch(browser = {}, launchOptions) {
return whenAllBuilt().then(() => {
const toLoad = definitions.filter(opts => (
!opts.validBrowsers || opts.validBrowsers.includes(browser.name)
));
if (toLoad.length > 0) {
const dirList = toLoad.map(o => o.destDir).join(',');
const existingLoadArgIndex = args.findIndex(arg => (
(typeof arg === 'string') && arg.startsWith('--load-extension=')
));
if (existingLoadArgIndex >= 0) {
// eslint-disable-next-line no-param-reassign
args[existingLoadArgIndex] = `${args[existingLoadArgIndex]},${dirList}`;
} else {
args.push(`--load-extension=${dirList}`);
}
const dirList = toLoad.map(o => o.destDir)
launchOptions.extensions.push(...dirList)
}
return config;
return launchOptions;
});
}

Expand Down
Loading

0 comments on commit 396efe8

Please sign in to comment.