Skip to content

Commit df4b407

Browse files
Fix dev-dependencies and test files requires (#41)
* Fix dev-dependencies and test files requires React was setup before Jest, so tests were never executed when I initially ported the project to npm and wally. React could not even depend on the jest packages. This PR is a first step towards making the test suite run: it corrects a lot of the requires in test files and also define each dev-dependency. This PR also enables the `@jsdotlua/react-noop-renderer` and `@jsdotlua/jest-react` to now be published! * fix format to skip snapshots
1 parent 2e652e7 commit df4b407

File tree

128 files changed

+710
-213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+710
-213
lines changed

.darklua.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"process": [
2+
"rules": [
33
{
44
"rule": "inject_global_value",
55
"identifier": "__DEV__",

.styluaignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
*.snap.lua
1+
*.snap.luau

foreman.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ rojo = { source = "rojo-rbx/rojo", version = "7.3.0" }
33
selene = { source = "Kampfkarren/selene", version = "0.26.1" }
44
stylua = { source = "JohnnyMorganz/StyLua", version = "=0.15.1" }
55
wally = { github = "UpliftGames/wally", version = "=0.3.2" }
6-
luau-lsp = { github = "johnnymorganz/luau-lsp", version = "=1.23.0" }
7-
darklua = { github = "seaofvoices/darklua", version = "=0.12.1" }
6+
luau-lsp = { github = "johnnymorganz/luau-lsp", version = "=1.35.0" }
7+
darklua = { github = "seaofvoices/darklua", version = "=0.14.0" }
88
lune = { github = "filiptibell/lune", version = "0.7.11" }
File renamed without changes.
File renamed without changes.
File renamed without changes.

modules/jest-react/package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@jsdotlua/jest-react",
3+
"version": "17.2.0",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/jsdotlua/react-lua.git",
7+
"directory": "modules/jest-react"
8+
},
9+
"license": "MIT",
10+
"main": "src/init.luau",
11+
"scripts": {
12+
"prepare": "npmluau"
13+
},
14+
"dependencies": {
15+
"@jsdotlua/jest-globals": "^3.6.1-rc.2",
16+
"@jsdotlua/luau-polyfill": "^1.2.6",
17+
"@jsdotlua/shared": "workspace:^"
18+
},
19+
"devDependencies": {
20+
"npmluau": "^0.1.0"
21+
}
22+
}

modules/react-cache/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"@jsdotlua/shared": "workspace:^"
1919
},
2020
"devDependencies": {
21+
"@jsdotlua/jest-globals": "^3.6.1-rc.2",
22+
"@jsdotlua/jest-react": "workspace:^",
23+
"@jsdotlua/promise": "^3.5.0",
24+
"@jsdotlua/react-test-renderer": "workspace:^",
2125
"npmluau": "^0.1.0"
2226
}
2327
}

modules/react-cache/src/__tests__/ReactCacheOld-internal.spec.luau

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe("ReactCache", function()
5252
Suspense = React.Suspense
5353
-- ROBLOX deviation START: fix require
5454
-- ReactCache = require_("react-cache")
55-
ReactCache = require(".")
55+
ReactCache = require("..")
5656
-- ROBLOX deviation END
5757
createResource = ReactCache.unstable_createResource
5858
-- ROBLOX deviation START: fix requires

modules/react-debug-tools/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"@jsdotlua/shared": "workspace:^"
1818
},
1919
"devDependencies": {
20+
"@jsdotlua/jest-globals": "^3.6.1-rc.2",
21+
"@jsdotlua/promise": "^3.5.0",
22+
"@jsdotlua/react": "workspace:^",
23+
"@jsdotlua/react-test-renderer": "workspace:^",
24+
"@jsdotlua/scheduler": "workspace:^",
2025
"npmluau": "^0.1.0"
2126
}
2227
}

modules/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration.spec.luau

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* @emails react-core
99
* @jest-environment node
1010
]]
11-
local Packages = script.Parent.Parent.Parent
1211
local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill")
1312
-- ROBLOX deviation START: not needed
1413
-- local Boolean = LuauPolyfill.Boolean

modules/react-debug-tools/src/__tests__/ReactHooksInspection.spec.luau

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* @emails react-core
99
* @jest-environment node
1010
]]
11-
local Packages = script.Parent.Parent.Parent
1211
-- ROBLOX deviation START: not needed
1312
-- local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill")
1413
-- local Boolean = LuauPolyfill.Boolean

modules/react-devtools-extensions/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"@jsdotlua/shared": "workspace:^"
2020
},
2121
"devDependencies": {
22+
"@jsdotlua/jest-globals": "^3.6.1-rc.2",
23+
"@jsdotlua/react-test-renderer": "workspace:^",
2224
"npmluau": "^0.1.0"
2325
}
2426
}

modules/react-devtools-shared/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"@jsdotlua/shared": "workspace:^"
2222
},
2323
"devDependencies": {
24+
"@jsdotlua/jest-globals": "^3.6.1-rc.2",
25+
"@jsdotlua/promise": "^3.5.0",
26+
"@jsdotlua/react-test-renderer": "workspace:^",
27+
"@jsdotlua/scheduler": "workspace:^",
2428
"npmluau": "^0.1.0"
2529
}
2630
}

modules/react-devtools-shared/src/__tests__/bridge.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* This source code is licensed under the MIT license found in the
66
* LICENSE file in the root directory of this source tree.
77
]]
8-
local Packages = script.Parent.Parent.Parent
98
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
109
local describe = JestGlobals.describe
1110
local it = JestGlobals.it
@@ -19,7 +18,7 @@ describe("bridge", function()
1918
beforeEach(function()
2019
jest.resetModules()
2120
jest.useFakeTimers()
22-
Bridge = require("./bridge")
21+
Bridge = require("../bridge")
2322
end)
2423

2524
it("should shutdown properly", function()

modules/react-devtools-shared/src/__tests__/console.spec.luau

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* This source code is licensed under the MIT license found in the
66
* LICENSE file in the root directory of this source tree.
77
]]
8-
local Packages = script.Parent.Parent.Parent
98
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
109
local describe = JestGlobals.describe
1110
local xit = JestGlobals.xit

modules/react-devtools-shared/src/__tests__/events.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
-- * @flow
99
-- */
1010

11-
local Packages = script.Parent.Parent.Parent
1211
local Error = require("@pkg/@jsdotlua/luau-polyfill").Error
1312
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1413
local describe = JestGlobals.describe
@@ -21,7 +20,7 @@ describe("events", function()
2120
local dispatcher
2221
beforeEach(function()
2322
jest.resetModules()
24-
local EventEmitter = require("./events")
23+
local EventEmitter = require("../events")
2524
dispatcher = EventEmitter.new()
2625
end)
2726

modules/react-devtools-shared/src/__tests__/profilerStore.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
* @flow
1010
]]
1111

12-
local Packages = script.Parent.Parent.Parent
1312
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1413
local jest = JestGlobals.jest
1514
local jestExpect = JestGlobals.expect
1615
local xdescribe = JestGlobals.xdescribe
1716
local it = JestGlobals.it
1817
local beforeEach = JestGlobals.beforeEach
1918

20-
local devtoolsTypes = require("./devtools/types")
19+
local devtoolsTypes = require("../devtools/types")
2120
type Store = devtoolsTypes.Store
2221

2322
local global = _G

modules/react-devtools-shared/src/__tests__/profilingCache.spec.luau

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*
99
* @flow
1010
]]
11-
12-
local Packages = script.Parent.Parent.Parent
1311
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1412
local jestExpect = JestGlobals.expect
1513
local xdescribe = JestGlobals.xdescribe
@@ -21,13 +19,13 @@ local afterEach = JestGlobals.afterEach
2119
local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill")
2220
local Error = LuauPolyfill.Error
2321

24-
local Bridge = require("./bridge")
22+
local Bridge = require("../bridge")
2523
type FrontendBridge = Bridge.FrontendBridge
2624

27-
local devtoolsTypes = require("./devtools/types")
25+
local devtoolsTypes = require("../devtools/types")
2826
type Store = devtoolsTypes.Store
2927

30-
local ProfilerTypes = require("./devtools/views/Profiler/types")
28+
local ProfilerTypes = require("../devtools/views/Profiler/types")
3129
type ProfilingDataFrontend = ProfilerTypes.ProfilingDataFrontend
3230

3331
local global = _G

modules/react-devtools-shared/src/__tests__/profilingCharts.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* @flow
1010
]]
1111

12-
local Packages = script.Parent.Parent.Parent
1312
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1413
local xdescribe = JestGlobals.xdescribe
1514
local beforeEach = JestGlobals.beforeEach
@@ -18,7 +17,7 @@ local describe = JestGlobals.describe
1817
local it = JestGlobals.it
1918
local jestExpect = JestGlobals.expect
2019

21-
local devtoolsTypes = require("./devtools/types")
20+
local devtoolsTypes = require("../devtools/types")
2221
type Store = devtoolsTypes.Store
2322

2423
xdescribe("profiling charts", function()

modules/react-devtools-shared/src/__tests__/profilingCommitTreeBuilder.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
* @flow
1111
]]
1212

13-
local Packages = script.Parent.Parent.Parent
1413
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1514
local xdescribe = JestGlobals.xdescribe
1615
local beforeEach = JestGlobals.beforeEach
1716
local it = JestGlobals.it
1817
local jestExpect = JestGlobals.expect
1918

20-
local devtoolsTypes = require("./devtools/types")
19+
local devtoolsTypes = require("../devtools/types")
2120
type Store = devtoolsTypes.Store
2221

2322
local global = _G

modules/react-devtools-shared/src/__tests__/profilingUtils.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* @flow
99
]]
1010

11-
local Packages = script.Parent.Parent.Parent
1211
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1312
local jestExpect = JestGlobals.expect
1413
local describe = JestGlobals.describe
@@ -18,7 +17,7 @@ local beforeEach = JestGlobals.beforeEach
1817
describe("profiling utils", function()
1918
local utils
2019
beforeEach(function()
21-
utils = require("./devtools/views/Profiler/utils")
20+
utils = require("../devtools/views/Profiler/utils")
2221
end)
2322
it("should throw if importing older/unsupported data", function()
2423
jestExpect(function()

modules/react-devtools-shared/src/__tests__/setupTests.luau

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ beforeEach(function()
3737
-- rather than imported at the head of the module.
3838
-- That's because we reset modules between tests,
3939
-- which disconnects the DevTool's cache from the current dispatcher ref.
40-
local Agent = require("./backend/agent")
41-
local initBackend = require("./backend").initBackend
42-
local Bridge = require("./bridge")
43-
local Store = require("./devtools/store")
44-
local installHook = require("./hook").installHook
45-
local utils = require("./utils")
40+
local Agent = require("../backend/agent")
41+
local initBackend = require("../backend").initBackend
42+
local Bridge = require("../bridge")
43+
local Store = require("../devtools/store")
44+
local installHook = require("../hook").installHook
45+
local utils = require("../utils")
4646
local getDefaultComponentFilters = utils.getDefaultComponentFilters
4747
local saveComponentFilters = utils.saveComponentFilters
4848

modules/react-devtools-shared/src/__tests__/store.spec.luau

+3-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ local fill = function(count, value)
1616
return output
1717
end
1818

19-
local Packages = script.Parent.Parent.Parent
2019
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
2120
local jest = JestGlobals.jest
2221
local jestExpect = JestGlobals.expect
@@ -36,7 +35,7 @@ type Array<T> = { [number]: T }
3635
local ReactRoblox
3736
local React
3837
-- ROBLOX deviation: bring in the Agent type
39-
local Agent = require("./backend/agent")
38+
local Agent = require("../backend/agent")
4039
type Agent = Agent.Agent
4140

4241
describe("Store", function()
@@ -54,8 +53,8 @@ describe("Store", function()
5453
React = require("@pkg/@jsdotlua/react")
5554
jest.resetModules()
5655
ReactRoblox = require("@pkg/@jsdotlua/react-roblox")
57-
devtoolsUtils = require("./devtools/utils")
58-
constants = require("./constants")
56+
devtoolsUtils = require("../devtools/utils")
57+
constants = require("../constants")
5958

6059
jest.useFakeTimers()
6160

modules/react-devtools-shared/src/__tests__/storeComponentFilters.spec.luau

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
]]
1111

1212
type Function = (...any) -> ...any
13-
local Packages = script.Parent.Parent.Parent
1413
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1514
local jest = JestGlobals.jest
1615
local describe = JestGlobals.describe
@@ -20,9 +19,9 @@ local jestExpect = JestGlobals.expect
2019

2120
local global = _G
2221

23-
local bridgeModule = require("./bridge")
22+
local bridgeModule = require("../bridge")
2423
type FrontendBridge = bridgeModule.FrontendBridge
25-
local devtoolsTypes = require("./devtools/types")
24+
local devtoolsTypes = require("../devtools/types")
2625
type Store = devtoolsTypes.Store
2726

2827
describe("Store component filters", function()
@@ -55,9 +54,9 @@ describe("Store component filters", function()
5554

5655
React = require("@pkg/@jsdotlua/react")
5756
ReactRoblox = require("@pkg/@jsdotlua/react-roblox")
58-
Types = require("./types")
57+
Types = require("../types")
5958
utils = require("./utils")
60-
devtoolsUtils = require("./devtools/utils")
59+
devtoolsUtils = require("../devtools/utils")
6160
end)
6261

6362
it("should throw if filters are updated while profiling", function()

modules/react-devtools-shared/src/__tests__/storeOwners.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* @flow
1010
]]
1111

12-
local Packages = script.Parent.Parent.Parent
1312
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1413
local jestExpect = JestGlobals.expect
1514
local describe = JestGlobals.describe
@@ -38,7 +37,7 @@ describeIfDev("Store owners list", function()
3837
Boolean = LuauPolyfill.Boolean
3938
React = require("@pkg/@jsdotlua/react")
4039
ReactRoblox = require("@pkg/@jsdotlua/react-roblox")
41-
devtoolsUtils = require("./devtools/utils")
40+
devtoolsUtils = require("../devtools/utils")
4241
printOwnersList = devtoolsUtils.printOwnersList
4342

4443
local utils = require("./utils")

modules/react-devtools-shared/src/__tests__/utils.luau

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ type Function = (...any) -> any?
2121
local global = _G
2222
local exports = {}
2323

24-
local Bridge = require("./bridge")
24+
local Bridge = require("../bridge")
2525
type FrontendBridge = Bridge.FrontendBridge
26-
local devtoolsTypes = require("./devtools/types")
26+
local devtoolsTypes = require("../devtools/types")
2727
type Store = devtoolsTypes.Store
28-
local ProfilerTypes = require("./devtools/views/Profiler/types")
28+
local ProfilerTypes = require("../devtools/views/Profiler/types")
2929
type ProfilingDataFrontend = ProfilerTypes.ProfilingDataFrontend
30-
local Types = require("./types")
30+
local Types = require("../types")
3131
type ElementType = Types.ElementType
3232

3333
exports.act = function(callback: () -> ()): ()
@@ -198,7 +198,7 @@ exports.requireTestRenderer = function(): any
198198
end
199199

200200
exports.exportImportHelper = function(bridge: FrontendBridge, store: Store): ()
201-
local utils = require("./devtools/views/Profiler/utils")
201+
local utils = require("../devtools/views/Profiler/utils")
202202
local prepareProfilingDataExport = utils.prepareProfilingDataExport
203203
local prepareProfilingDataFrontendFromExport =
204204
utils.prepareProfilingDataFrontendFromExport

modules/react-devtools-shared/src/__tests__/utils.spec.luau

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-- *
88
-- * @flow
99
-- */
10-
local Packages = script.Parent.Parent.Parent
1110
local JestGlobals = require("@pkg/@jsdotlua/jest-globals")
1211
local jestExpect = JestGlobals.expect
1312
local describe = JestGlobals.describe
@@ -17,7 +16,7 @@ local beforeEach = JestGlobals.beforeEach
1716
local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill")
1817
local Symbol = LuauPolyfill.Symbol
1918

20-
local utils = require("./utils")
19+
local utils = require("../utils")
2120
local getDisplayName = utils.getDisplayName
2221
local getDisplayNameForReactElement = utils.getDisplayNameForReactElement
2322
local SuspenseList, StrictMode

modules/react-devtools-shared/src/devtools/views/Profiler/FlamegraphChartBuilder.luau

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Set<T> = LuauPolyfill.Set<T>
1818

1919
local exports = {}
2020

21-
local devtoolsTypes = require("./types")
21+
local devtoolsTypes = require("../../types")
2222
type ProfilerStore = devtoolsTypes.ProfilerStore
2323

2424
local formatDuration = require("./utils").formatDuration

0 commit comments

Comments
 (0)