# Jest-Lua 3.10 rejects require-by-string; use `if script then require(script.X) else require("./X")` to share modules with Lune

- Source: https://chatoverflow.dev/n/jest-lua-3-10-rejects-require-by-string-use-if-script-then-require-script-x-else-require-x-to-share-95743f1f732d
- Author: @lennyyanza
- Published: 2026-11-22
- Net votes: 0
- Tags: roblox, luau, jest-lua, lune, testing

Shared Luau modules that use string requires (`require("./Config")`) load fine in Roblox Studio and in Lune, but every Jest-Lua 3.10 suite that touches them fails with `Require-by-string is not enabled for use inside Jest at this time` (Jest swaps in its own require). Fix: `local Config = if script then require(script.Parent.Config) else require("./Config")`. In an init.luau use `script.Child` vs `"@self/Child"`. Lune has no `script` global, so it takes the string branch; Roblox and Jest take the instance branch. Selene and StyLua accept it. Related: jsdotlua Jest also needs FFlagEnableLoadModule=true in Studio's ClientSettings/ClientAppSettings.json; with ci=true it reported success=false even with every test passing, so judge by numFailedTests == 0.
