Код: Выделить всё
myapp
- packages
- app1
- src
...
package.json
- app2
- src
...
package.json
- app3
- src
...
package.json
package.json
Код: Выделить всё
{
"name": "myapp",
"type": "module",
"scripts": {
"preview:watch": "npm run preview --workspaces --if-present"
"e2e:open": "concurrently --kill-others \"npm run preview:watch\" \"cypress open --e2e --browser chrome\"",
"e2e:headless": "cypress run --e2e --headless",
"e2e:coverage": "nyc report --reporter=text --reporter=text-summary --reporter=lcov"
},
"nyc": {
"report-dir": "cypress-coverage"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
},
"devDependencies": {
"@cypress/code-coverage": "^3.12.44",
"vite": "^5.0.8",
"vite-plugin-istanbul": "^6.0.2"
},
"workspaces": [
"packages/app1",
"packages/app2",
"packages/app3"
]
}
Код: Выделить всё
⚠️ file /Users/abc/projects/myapp/.nyc_output/out.json has no coverage information
[1] Did you forget to instrument your web application? Read https://github.com/cypress-io/code-coverage#instrument-your-application
[1] code-coverage ⚠️ file /Users/abc/projects/myapp/.nyc_output/out.json has no coverage information +18s
vite.config.js
Код: Выделить всё
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import istanbul from "vite-plugin-istanbul";
export default ({ mode }, packagePath, chunks) => {
return defineConfig({
define: {
"process.env": JSON.stringify(process.env),
},
plugins: [
react(),
istanbul({
include: "**",
forceBuildInstrument: true,
cwd: "../.."
}),
],
esbuild: {
loader: "jsx",
},
build: {
lib: {
entry: resolve(__dirname, `${packagePath}/src/App.jsx`),
name: "myapp",
fileName: "index",
formats: ["es"],
},
rollupOptions: {
output: {
entryFileNames: "index.js",
assetFileNames: "index.css",
manualChunks: chunks,
},
},
},
preview: {
port: 3000,
open: "http://localhost:8080/landing.html",
},
resolve: {
alias: {
"@parent": path.resolve(__dirname, "."),
"@app1": path.resolve(__dirname, "./packages/app1"),
"@app2": path.resolve(__dirname, "./packages/app2"),
"@app3": path.resolve(__dirname, "./packages/app3")
},
},
});
};
Подробнее здесь: https://stackoverflow.com/questions/794 ... strumented