Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Latest loopback mocha tests are not running

Đang mở
#9,561 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
nodejs, typescript
Lĩnh vực
testing-qa

Hướng nghiên cứu

Chạy yarn test trong một ứng dụng LoopBack mới được tạo bằng Node 16 và kiểm tra thiết lập kiểm thử được tạo cùng các phiên bản dependency liên quan đến Mocha và yargs. Được xem là hoàn tất khi các bài kiểm thử Mocha mặc định chạy mà không gặp lỗi ERR_REQUIRE_ESM đã được báo cáo, đồng thời vẫn giữ các phiên bản dependency theo dự kiến.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug Testlab
Describe the bug

Create a new lb app with node 16,
Trying to run the default tests that come with lb app, using yarn test, it immediately throws this typescript error. This seems to be a mocha issue, but why did Loopback upgrade to latest mocha?

ERR_REQUIRE_ESM errors with Mocha tests.

const stringWidth = require('string-width');
                    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/fahad/work/testapp/node_modules/string-width/index.js from /home/fahad/work/testapp/node_modules/yargs/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /home/fahad/work/testapp/node_modules/yargs/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/fahad/work/testapp/node_modules/yargs/node_modules/cliui/build/index.cjs:291:21)
    at Object.<anonymous> (/home/fahad/work/testapp/node_modules/yargs/build/index.cjs:2861:12)
    at Object.<anonymous> (/home/fahad/work/testapp/node_modules/yargs/yargs:3:69)
    at Object.<anonymous> (/home/fahad/work/testapp/node_modules/mocha/lib/cli/cli.js:15:15)
    at Object.<anonymous> (/home/fahad/work/testapp/node_modules/mocha/bin/mocha.js:141:3) {
  code: 'ERR_REQUIRE_ESM'
}
Logs

No response

Additional information

If I downgrade yargs library to 14.2.2, this issue is not occurring.

Reproduction

THIS ISSUE IS OBVIOUS

Ngôn ngữ chính
TypeScript
Star
5.1k
Fork
1.1k
Merge trung bình
5 ngày 9 giờ
Pull request đã merge (30 ngày)
28

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của loopbackio/loopback-next

Tất cả issue của loopbackio/loopback-next

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.