`td.imitate` produces `undefined` for object keys of type `Accessor`
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- testing-qa
Línea de trabajo
Start at the td.imitate entry point and reproduce the class instance case under the Jest/SWC setup described in the issue. Add a regression test in the regression/src directory, using the Accessor and Function properties shown; done means the imitation no longer produces undefined for the Accessor property while preserving the method.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
I'm working on a Next.js app that uses testdouble.js for mocking dependencies in tests. Our test environment uses Jest and runs under Babel. This issue revealed itself when attempting to alter our Jest config to use the Next.js Compiler (SWC) as described here.
The following code snippet run under Babel results in a passing test.
const myDependency = td.replace("../lib");
td.when(myDependency.doTheThing()).thenReturn(123);
expect(myFunction()).toBe("some result");
The same test run under SWC fails with the error
TypeError: myDependency.doTheThing() is not a function
Issue
Objects with Accessor properties result in undefined when run through td.imitate.
For example, given:
class Foo {
get bar() {
return 0;
}
baz() {
return 1;
}
}
The line:
const instance = new Foo();
produces an object with the type
{ bar: Accessor, baz: Function }
Running the class instance through td.imitate
const imitation = td.imitate(instance);
results in an object with the type
{ bar: undefined, baz: Function }
Environment
-
node -voutput: -
npm -v(oryarn --version) output: -
npm ls testdouble(oryarn list testdouble) version:
Failing Test
- Fork the repo
- Add a failing test (probably to the `/regression/src' directory)
- Submit a pull request for the failing test or link to your branch here
Example Repo
- Create a minimal repository that reproduces the issue
- Make sure that a fresh clone can run only
npm itand observe the issue - Link to that repo here
Runkit Notebook
- Create a Runkit notebook
- Invoke
var td = require('testdouble')at the top - Verify the behavior your issue is concerned with by clicking "Run"
- Link to the Runkit here
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.4k
- Forks
- 140
- Merge medio
- 7 h 51 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Aún no hemos revisado los archivos de configuración de este proyecto. Empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 testdouble/testdouble.js
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
testdouble/testdouble.js#538 · 1 comentario ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
testdouble/testdouble.js#537 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
testdouble/testdouble.js#536 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
testdouble/testdouble.js#534 ·
-
`npm-run-all` to `npm-run-all2`Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 45/100
testdouble/testdouble.js#533 ·
Todos los issues de testdouble/testdouble.js
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
solana-foundation/solana-com#2202 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
yegor256/copyrights-action#216 ·
-
[BUG] onScroll never refreshes the window container's height after a vertical-only viewport resizeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
juliangarnier/anime#1192 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
PedestrianDynamics/pyFDS-Evac#226 ·
Los mantenedores suelen responder en 1 día