Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

possible to replace subset of exports from module?

Aperta
#536 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
testing

Direzione di ricerca

Start with td.test.js and the replaceEsm entry point to determine whether partial export replacement is supported. Use sample.js as the fixture and make the test demonstrate preserving a while replacing b; done means both assertions pass without moving the functions.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

sample.js

export {a, b}

function a() {
  return b()
}

function b() {
  return 'b'
}

want to replace b() but preserve a()...

td.test.js

import test from 'ava'
import * as td from 'testdouble'
// import {a} from './sample.js'

let mock

test.beforeEach(async () => {
  // unclear how to use second parameter here, is this a potential solution?
  // or is the ask not supported and would need to place `a` and `b` in separate files?
  //
  mock = await td.replaceEsm('./sample.js')
})

test.afterEach(async () => {
  td.reset()
})

test('a', (t) => {
  td.when(mock.b()).thenResolve('bee')
  t.is(mock.a(), 'bee')
})

test('b', (t) => {
  td.when(mock.b()).thenReturn('be')
  t.is(mock.b(), 'be')
})
Lingua principale
JavaScript
Stelle
1.4k
Fork
140
Merge medio
5h 55m
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di testdouble/testdouble.js

Tutte le issue di testdouble/testdouble.js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.