`td.imitate` produces `undefined` for object keys of type `Accessor`
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- testing-qa
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- JavaScript
- スター
- 1.4k
- フォーク
- 140
- 平均マージ
- 7時間 51分
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
testdouble/testdouble.js のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
testdouble/testdouble.js#538 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
testdouble/testdouble.js#537 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
testdouble/testdouble.js#536 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
testdouble/testdouble.js#534 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 45/100
testdouble/testdouble.js#533 ·
testdouble/testdouble.js の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
solana-foundation/solana-com#2202 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
yegor256/copyrights-action#216 ·
-
[BUG] onScroll never refreshes the window container's height after a vertical-only viewport resizeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
juliangarnier/anime#1192 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
PedestrianDynamics/pyFDS-Evac#226 ·
メンテナーはふだん 1 日以内に返信