diff --git a/packages/nodejs/src/repro/foo.ts b/packages/nodejs/src/repro/foo.ts new file mode 100644 index 000000000..109b6b19f --- /dev/null +++ b/packages/nodejs/src/repro/foo.ts @@ -0,0 +1,12 @@ +export class Foo { + readonly #bar: string; + + constructor(bar: string) { + this.#bar = bar; + } + + async baz(): Promise { + await new Promise((resolve) => setTimeout(resolve, 100)); + return `Hello ${this.#bar}`; + } +} diff --git a/packages/nodejs/src/repro/makeFoo.test.ts b/packages/nodejs/src/repro/makeFoo.test.ts new file mode 100644 index 000000000..2236118c9 --- /dev/null +++ b/packages/nodejs/src/repro/makeFoo.test.ts @@ -0,0 +1,20 @@ +import { expect, describe, it, vi } from 'vitest'; + +import { makeFoo } from './makeFoo.ts'; + +const mocks = vi.hoisted(() => { + const Foo = vi.fn(); + Foo.prototype.baz = vi.fn().mockResolvedValue('Hello fizz'); + return { Foo }; +}); + +vi.mock('./foo.ts', () => ({ + Foo: mocks.Foo, +})); + +describe('makeFoo', () => { + it('should make a Foo', async () => { + const foo = makeFoo('baz'); + expect(foo).toBeInstanceOf(mocks.Foo); + }); +}); diff --git a/packages/nodejs/src/repro/makeFoo.ts b/packages/nodejs/src/repro/makeFoo.ts new file mode 100644 index 000000000..bf11b8c59 --- /dev/null +++ b/packages/nodejs/src/repro/makeFoo.ts @@ -0,0 +1,12 @@ +import { Foo } from './foo.ts'; + +/** + * Make a Foo + * + * @param bar - The bar to use for the Foo + * + * @returns A Foo + */ +export function makeFoo(bar: string): Foo { + return new Foo(bar); +} diff --git a/vitest.config.ts b/vitest.config.ts index 28d136486..8a1cda8d8 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -101,10 +101,10 @@ export default defineConfig({ lines: 100, }, 'packages/nodejs/**': { - statements: 72.91, - functions: 83.33, + statements: 67.92, + functions: 68.75, branches: 63.63, - lines: 72.91, + lines: 69.23, }, 'packages/rpc-methods/**': { statements: 100, @@ -139,4 +139,4 @@ export default defineConfig({ }, }, }, -}); +}); \ No newline at end of file