Stubbing a CJS module from an ESM
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 32/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
- 領域
- devtools, testing-qa
調査の方向性
Start by running examples/node-esm/test/lib/numbers-only-test.mjs and trace td.replace('is-number') before ../../lib/numbers-only.mjs is dynamically imported. Check the ESM/CJS module-loading path involved in that example; done means the fake is-number module is used and the test assertion passes.
索引モデルが issue の本文から書いたものです。
説明
Description
In the testdouble repo, I created examples/node-esm/test/lib/numbers-only-test.mjs with the following code.
import assert from 'assert'
import mocha from 'mocha'
import * as td from 'testdouble'
mocha.describe('numbers-only', function () {
mocha.it.only('goes boom', async function () {
const isNumber = td.replace('is-number');
const numbersOnly = await import('../../lib/numbers-only.mjs')
td.when(isNumber('a string')).thenReturn(true) // tee-hee, this is silly
const result = numbersOnly.default('a string')
assert.equal(result, true)
});
});
Based on what I read from the docs, I would expect this code to pass, but whenever ../../lib/numbers-only.mjs is loaded, the real is-number is resolved instead of the faked module.
Issue
the real module is being loaded instead of the fake.
Environment
-
node -v20.1.0 or 22.3.0: -
npm -v(oryarn --version) output: 10.5.2 or 10.8.1 -
npm ls testdouble(oryarn list testdouble) version: from the example
Failing Test
See above
Example Repo
See above
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
Code-fenced Examples
var td = require('testdouble')
// Your steps here.
- 主要言語
- JavaScript
- スター
- 1.4k
- フォーク
- 140
- 平均マージ
- 5時間 55分
- マージ済み PR(30日)
- 4
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず 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時間 初心者へのやさしさ 85/100
mozilla/bedrock#17413 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
automated issue report
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
lirantal/discoprint#31 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
meshery/meshery.io#3040 ·
メンテナーはふだん 1 日以内に返信
-
Internationalization p5.js 2.0+
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
processing/p5.js#9231 ·
メンテナーはふだん 2 日以内に返信