-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove browserify and add webpack as preprocessor to fix failing…
… cypress tests
- Loading branch information
1 parent
f966cd7
commit 222770d
Showing
4 changed files
with
144 additions
and
1,223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,45 @@ | ||
// Cypress no longer natively supports plugins file, but we keep it for better code abstraction | ||
// https://docs.cypress.io/app/references/migration-guide#Plugins-File-Removed | ||
|
||
const task = require("@cypress/code-coverage/task"); | ||
const browserify = require("@cypress/browserify-preprocessor"); | ||
|
||
// In order to use both babelrc and typescript in browserify | ||
// we copy the functionality from @cypress/code-coverage/use-babelrc | ||
// and merge it with the typescript setting. | ||
// The plugin @cypress/code-coverage/use-babelrc basically | ||
// sets babelrc: true in the browserify options. | ||
const { browserifyOptions } = browserify.defaultOptions; | ||
browserifyOptions.transform[1][1].babelrc = true; | ||
const webpackPreprocessor = require("@cypress/webpack-preprocessor"); | ||
|
||
module.exports = (on, config) => { | ||
task(on, config); | ||
on( | ||
"file:preprocessor", | ||
browserify({ | ||
typescript: require.resolve("typescript"), | ||
browserifyOptions: { | ||
extensions: [".js", ".ts"], | ||
...browserifyOptions | ||
|
||
const options = { | ||
webpackOptions: { | ||
resolve: { | ||
extensions: [".ts", ".tsx", ".js", ".jsx"], | ||
modules: ["node_modules", "src"] | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: [ | ||
{ | ||
loader: "ts-loader", | ||
options: { | ||
transpileOnly: true, | ||
compilerOptions: { | ||
module: "esnext", | ||
target: "es5", | ||
lib: ["es5", "dom"], | ||
jsx: "react", | ||
allowJs: true, | ||
esModuleInterop: true, | ||
allowSyntheticDefaultImports: true, | ||
noEmit: false | ||
} | ||
} | ||
} | ||
], | ||
exclude: /node_modules/ | ||
} | ||
] | ||
} | ||
}) | ||
); | ||
} | ||
}; | ||
|
||
on("file:preprocessor", webpackPreprocessor(options)); | ||
|
||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.