mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
@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:
parent
9cab3b65ec
commit
23d72d25e4
@ -1,4 +1,3 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const BlinkDiff = require('blink-diff');
|
const BlinkDiff = require('blink-diff');
|
||||||
|
|
||||||
function compareSnapshotsPlugin(args) {
|
function compareSnapshotsPlugin(args) {
|
@ -1,26 +0,0 @@
|
|||||||
const wp = require('@cypress/webpack-preprocessor');
|
|
||||||
|
|
||||||
const webpackOptions = {
|
|
||||||
resolve: {
|
|
||||||
extensions: ['.ts', '.js'],
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.ts$/,
|
|
||||||
exclude: [/node_modules/],
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'ts-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
webpackOptions,
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = wp(options);
|
|
@ -1,6 +1,6 @@
|
|||||||
const compareSnapshotsPlugin = require('./cy-compare-images');
|
const compareSnapshotsPlugin = require('./compareSnapshots');
|
||||||
const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor');
|
const extendConfig = require('./extendConfig');
|
||||||
const extendConfigPlugin = require('./cy-extend-config');
|
const typescriptPreprocessor = require('./typescriptPreprocessor');
|
||||||
|
|
||||||
module.exports = (on, config) => {
|
module.exports = (on, config) => {
|
||||||
// yarn build fails with:
|
// yarn build fails with:
|
||||||
@ -9,10 +9,8 @@ module.exports = (on, config) => {
|
|||||||
// on('task', {
|
// on('task', {
|
||||||
// failed: require('cypress-failed-log/src/failed')(),
|
// failed: require('cypress-failed-log/src/failed')(),
|
||||||
// });
|
// });
|
||||||
on('file:preprocessor', cypressTypeScriptPreprocessor);
|
on('file:preprocessor', typescriptPreprocessor);
|
||||||
on('task', {
|
on('task', { compareSnapshotsPlugin });
|
||||||
compareSnapshotsPlugin,
|
|
||||||
});
|
|
||||||
on('task', {
|
on('task', {
|
||||||
log({ message, optional }) {
|
log({ message, optional }) {
|
||||||
optional ? console.log(message, optional) : console.log(message);
|
optional ? console.log(message, optional) : console.log(message);
|
||||||
@ -22,5 +20,5 @@ module.exports = (on, config) => {
|
|||||||
|
|
||||||
// Always extend with this library's config and return for diffing
|
// Always extend with this library's config and return for diffing
|
||||||
// @todo remove this when possible: https://github.com/cypress-io/cypress/issues/5674
|
// @todo remove this when possible: https://github.com/cypress-io/cypress/issues/5674
|
||||||
return extendConfigPlugin(config);
|
return extendConfig(config);
|
||||||
};
|
};
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
const { resolve } = require('path');
|
||||||
|
const wp = require('@cypress/webpack-preprocessor');
|
||||||
|
|
||||||
|
const packageRoot = resolve(`${__dirname}/../../`);
|
||||||
|
const packageModules = `${packageRoot}/node_modules`;
|
||||||
|
|
||||||
|
const webpackOptions = {
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
include: modulePath => {
|
||||||
|
return modulePath.startsWith(packageRoot) && !modulePath.startsWith(packageModules);
|
||||||
|
},
|
||||||
|
test: /\.ts$/,
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: {
|
||||||
|
configFile: `${__dirname}/../tsconfig.json`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.ts', '.js'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
webpackOptions,
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = wp(options);
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
"types": ["cypress"]
|
"types": ["cypress"]
|
||||||
},
|
},
|
||||||
"extends": "../tsconfig.json",
|
"extends": "@grafana/tsconfig",
|
||||||
"include": ["**/*.ts"]
|
"include": ["**/*.ts"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user