`.nyc_output/out.json` is an empty object when using with `@cypress/react`
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- babel, node.js, typescript
- Área
- testing
Línea de trabajo
Comienza con el repositorio de reproducción enlazado y ejecuta npm test para confirmar el .nyc_output/out.json vacío. Después, inspecciona package.json, cypress/plugins/index.cjs y la configuración de Cypress para comprobar la configuración de ESM, las pruebas de componentes y la instrumentación. Se considera terminado cuando los datos de cobertura aparecen en .nyc_output/out.json y el informe generado contiene los archivos probados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Logs and screenshots
Please provide debug logs by running Cypress from the terminal with DEBUG=code-coverage environment variable set, see the Debugging section of the README file.
Debug logs
code-coverage reset code coverage in interactive mode +0ms
code-coverage parsed sent coverage +32ms
code-coverage wrote coverage file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json +1ms
code-coverage parsed sent coverage +25ms
code-coverage wrote coverage file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json +0ms
⚠️ file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json has no coverage information
Did you forget to instrument your web application? Read https://github.com/cypress-io/code-coverage#instrument-your-application
code-coverage ⚠️ file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json has no coverage information +8s
code-coverage ⚠️ file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json has no coverage information +1ms
code-coverage calling NYC reporter with options { 'report-dir': '/Users/chrisrzhou/Github/cypress-coverage-repo/coverage', reporter: [ 'lcov', 'clover', 'json', 'json-summary' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: false, 'temp-dir': '/Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output', tempDir: '/Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output', reportDir: '/Users/chrisrzhou/Github/cypress-coverage-repo/coverage' } +7ms
code-coverage current working directory is /Users/chrisrzhou/Github/cypress-coverage-repo +0ms
code-coverage after reporting, returning the report folder name /Users/chrisrzhou/Github/cypress-coverage-repo/coverage +40ms
code-coverage Final coverage in /Users/chrisrzhou/Github/cypress-coverage-repo/coverage/coverage-final.json +0ms
code-coverage There are 0 key(s) in /Users/chrisrzhou/Github/cypress-coverage-repo/coverage/coverage-final.json +0ms
Versions
- What is this plugin's version? @cypress/[email protected] (latest)
- What is Cypress version? [email protected], @cypress/[email protected], @cypress/[email protected] (see
package.jsonin repo for more details). - What is your operating system? Mac
- What is the shell? zsh
- What is the Node version? v12.22.1
- What is the NPM version? 6.14.12
- How do you instrument your application? Through the official docs' recommendation. See repo below for details.
- When running tests, if you open the web application in regular browser, and open DevTools, do you see
window.__coverage__object? Following the official docs, I can seewindow.__coverage__object for the files that the test is touching.

- Is there
.nyc_outputfolder? Is there.nyc_output/out.jsonfile. Is it empty? Both folder and file exists, the contents is just the empty object{}. - Do you have any custom NYC settings in
package.json(nycobject) or in other NYC config files No - Do you run Cypress tests in a Docker container? No, just locally
Describe the bug
Bug Report
Repro Link
https://github.com/chrisrzhou/cypress-code-coverage-issue-472
Context
It is a minimal example with the following requirements:
- Is an ESM module
- i.e.
"type": "module"is explicitly marked in thepackage.json - appropriate Cypress files need to be marked as
.cjsin order for the tests to run.
Incypress/plugins/index.cjsand fields incypress.json.
- i.e.
- Uses component testing (i.e.
@cypress/reactand usingopen-ctandrun-cttest runners). - Uses code coverage (i.e.
@cypress/code-coverageandbabel-plugin-istanbulbased on the official docs for instrumentation).
The requirements above are needed in the actual bug faced in the project, so the repo is capturing the minimal configuration of reproducing the same bug.
Reproduce
npm i
npm test
The test runner runs fine, and tests the code correctly.
Expected Behavior
Code coverage to output something meaningful in .nyc_output/out.json
Actual Behavior
.nyc_output/out.json is an empty object. The test runner complains that the code is not instrumented.
- Lenguaje dominante
- TypeScript
- Estrellas
- 440
- Forks
- 114
- Merge medio
- 42 min
- PR fusionados (30 d)
- 19
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de cypress-io/code-coverage
-
Dificultad 3/5 Medio día Aptitud para principiantes 40/100
cypress-io/code-coverage#1018 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
cypress-io/code-coverage#993 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
cypress-io/code-coverage#967 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
cypress-io/code-coverage#959 ·
Los mantenedores suelen responder en 1 día
-
performance
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
cypress-io/code-coverage#933 ·
Los mantenedores suelen responder en 1 día
Todos los issues de cypress-io/code-coverage
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 2 días
-
reproduced
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
anomalyco/opencode#62052 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
strapi/design-system#2084 ·
Los mantenedores suelen responder en 3 días
-
Report: &TV InternationalAbiertocheck:passed streams:remove
Dificultad 1/5 Menos de una hora Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día
-
OAuth documentation for GET /api/v2/users/me/ appears inconsistent with required global read scopeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día