Skip to content

[@web/test-runner] Very basic Solid.js example not working inside Web Test Runner unit test #2985

Open

Description

@trusktr

Hi, I've got a very basic Solid.js effect example not working within Web Test Runner.

Here's the most minimal reproduction.

The WTR config defines an import map to import Solid.js from CDN.

The same example, with the same importmap, works fine on CodePen.

Any idea if there's something in WTR's environment that could be messing with globals to somehow cause this?

Activity

  1. trusktr commented on Sep 27, 2025

    @trusktr
    Author

    A workaround is to change this,

    import { createEffect } from "solid-js"
    import { createMutable } from "solid-js/store"

    to this

    // import { createEffect } from "solid-js"
    // import { createMutable } from "solid-js/store"
    
    const { createEffect } = await eval('import("solid-js")')
    const { createMutable } = await eval('import("solid-js/store")')

    and it works!

    To workaround missing type definitions due to eval, I can do this:

    const { createEffect } = /** @type {typeof import("solid-js")} */ (await eval('import("solid-js")')) 
    const { createMutable } = /** @type {typeof import("solid-js/store")} */ (await eval('import("solid-js/store")'))

    It appears that WTR's default build is transforming the code (f.e. the import statements) that leads to the breakage for some reason. Importing natively, based on the importmap pointing to CDN, works fine.

    (I have solid-js installed locally only for making type definitions available.)

  2. trusktr commented on Sep 27, 2025

    @trusktr
    Author

    It would be nicer if I could disable all source transformation to keep native import working as expected:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions