@grafana/e2e: fix runtime ts-loader errors with Cypress support files (#22688)
* Minor changes * Only exclude installed packages that are not @grafana/e2e itself * Explicitly load Cypress tsconfig for clarity * Fix Cypress tsconfig * it was trying to extend a config that is not published * it needs to be commonjs
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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user