Skip to content

[Bug]: Cannot execute the defineConfig function in a Jest test #532

@patricklafrance

Description

@patricklafrance

Version

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13700H
    Memory: 9.70 GB / 31.62 GB
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @rsbuild/core: 1.1.8 => 1.1.8

Details

When executing the defineConfig function in a Jest test, I get the following error:

TypeError: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 'http://localhost/main.js'

The code under test:

import { defineConfig } from "@rsbuild/core";

export function myDefineConfig() {
    return defineConfig({});
}

The test:

import { myDefineConfig } from "../src/myDefineConfig.ts";

test("my test", () => {
    const config = myDefineConfig();

    expect(config).toMatchSnapshot();
});

I found this example which inspired most of my reproduction configs. It seems like something changed since this example has been created.

Reproduce link

https://github.com/patricklafrance/rsbuild-jest

Reproduce Steps

  • pnpm install
  • pnpm test

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions