`td.imitate` produces `undefined` for object keys of type `Accessor`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- testing-qa
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- JavaScript
- Stelle
- 1.4k
- Fork
- 140
- Merge medio
- 7h 51m
- PR unite (30g)
- 3
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di testdouble/testdouble.js
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
testdouble/testdouble.js#538 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
testdouble/testdouble.js#537 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
testdouble/testdouble.js#536 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
testdouble/testdouble.js#534 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 45/100
testdouble/testdouble.js#533 ·
Tutte le issue di testdouble/testdouble.js
Issue simili
-
Design only Leadership Survey SLFS
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
bcgov/digital-journeys#2293 ·
-
Toolkit
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
API Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ProjectSidewalk/SidewalkWebpage#5556 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
jessepollak/home#1454 ·
I maintainer di solito rispondono entro 1 giorno
-
Mend: dependency security vulnerability untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
opensearch-project/OpenSearch-Dashboards#12822 ·
I maintainer di solito rispondono entro 1 giorno