`td.imitate` produces `undefined` for object keys of type `Accessor`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- JavaScript
- Star
- 1.4k
- Fork
- 140
- Merge trung bình
- 7 giờ 51 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của testdouble/testdouble.js
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
testdouble/testdouble.js#538 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
testdouble/testdouble.js#537 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
testdouble/testdouble.js#536 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
testdouble/testdouble.js#534 ·
-
`npm-run-all` to `npm-run-all2`Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 45/100
testdouble/testdouble.js#533 ·
Tất cả issue của testdouble/testdouble.js
Issue tương tự
-
factory-active factory-automatic harness/codex task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
vercel/ai#21582 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ux
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
rr-djk/rr-djuikoo.com#53 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add shacl12-inference-rulesĐang mởnew spec review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
w3c/browser-specs#2666 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
thim81/openapi-format#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
decentespresso/dye2#13 ·