@grafana/e2e: added support for plugin repositories (#22546)
* Minor changes * Include Cypress support files in published package * Added CLI … with support for custom configurations (which Cypress does not currently support by default): * Loads cypress.json from @grafana/e2e as a base config (via a custom Cypress plugin) * Sets default values for project-level Cypress files (tests, etc) * Optionally loads a cypress.json from the current working directory as overrides * Updated lockfile
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
const {
|
||||
promises: { readFile },
|
||||
} = require('fs');
|
||||
const { resolve } = require('path');
|
||||
|
||||
module.exports = async baseConfig => {
|
||||
// From CLI
|
||||
const {
|
||||
env: { CWD },
|
||||
} = baseConfig;
|
||||
|
||||
if (CWD) {
|
||||
const projectConfig = {
|
||||
integrationFolder: `${CWD}/cypress/integration`,
|
||||
screenshotsFolder: `${CWD}/cypress/screenshots`,
|
||||
videosFolder: `${CWD}/cypress/videos`,
|
||||
};
|
||||
|
||||
const customProjectConfig = await readFile(`${CWD}/cypress.json`, 'utf8')
|
||||
.then(JSON.parse)
|
||||
.then(config => {
|
||||
const pathKeys = [
|
||||
'fileServerFolder',
|
||||
'fixturesFolder',
|
||||
'ignoreTestFiles',
|
||||
'integrationFolder',
|
||||
'pluginsFile',
|
||||
'screenshotsFolder',
|
||||
'supportFile',
|
||||
'testFiles',
|
||||
'videosFolder',
|
||||
];
|
||||
|
||||
return Object.fromEntries(
|
||||
Object.entries(config).map(([key, value]) => {
|
||||
if (pathKeys.includes(key)) {
|
||||
return [key, resolve(CWD, value)];
|
||||
} else {
|
||||
return [key, value];
|
||||
}
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.code === 'ENOENT') {
|
||||
// File is optional
|
||||
return null;
|
||||
} else {
|
||||
// Unexpected error
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
return { ...baseConfig, ...projectConfig, ...customProjectConfig };
|
||||
} else {
|
||||
// Temporary legacy support for Grafana core (using `yarn start`)
|
||||
return baseConfig;
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,8 @@
|
||||
const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor');
|
||||
const compareSnapshotsPlugin = require('./cy-compare-images');
|
||||
const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor');
|
||||
const extendConfigPlugin = require('./cy-extend-config');
|
||||
|
||||
module.exports = on => {
|
||||
module.exports = (on, config) => {
|
||||
// yarn build fails with:
|
||||
// >> /Users/hugo/go/src/github.com/grafana/grafana/node_modules/stringmap/stringmap.js:99
|
||||
// >> throw new Error("StringMap expected string key");
|
||||
@@ -13,9 +14,13 @@ module.exports = on => {
|
||||
compareSnapshotsPlugin,
|
||||
});
|
||||
on('task', {
|
||||
log(args) {
|
||||
args.optional ? console.log(args.message, args.optional) : console.log(args.message);
|
||||
log({ message, optional }) {
|
||||
optional ? console.log(message, optional) : console.log(message);
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
// Always extend with this library's config and return for diffing
|
||||
// @todo remove this when possible: https://github.com/cypress-io/cypress/issues/5674
|
||||
return extendConfigPlugin(config);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user