Skip to content

Commit 35a5ddd

Browse files
author
RoFlection Bot
committed
Switched Tests to use Jest : Purge TestEz -> Anoint Jest (#64)
1 parent 60ca1fd commit 35a5ddd

24 files changed

+4525
-4686
lines changed

bin/spec.lua

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
local Root = game:GetService("ReplicatedStorage")
2-
32
local Packages = Root.Packages
43

5-
local JestGlobals = require(Packages.JestGlobals)
4+
local runCLI = require(Packages.JestCore).runCLI
65

7-
local TestEZ = JestGlobals.TestEZ
6+
local status, result = runCLI(Root, {
7+
verbose = _G.verbose == "true",
8+
ci = _G.CI == "true",
9+
updateSnapshot = _G.UPDATESNAPSHOT == "true",
10+
}, { Packages.DomTestingLibrary }):awaitStatus()
811

9-
-- Run all tests, collect results, and report to stdout.
10-
TestEZ.TestBootstrap:run(
11-
{ Packages.DomTestingLibrary },
12-
TestEZ.Reporters.pipe({
13-
TestEZ.Reporters.JestDefaultReporter,
14-
TestEZ.Reporters.JestSummaryReporter,
15-
}),
16-
{
17-
extraEnvironment = JestGlobals.testEnv,
18-
}
19-
)
20-
-- ROBLOX TODO: after converting jest-runner this should be included there
21-
JestGlobals.runtime:teardown()
12+
if status == "Rejected" then
13+
print(result)
14+
end
2215

2316
return nil

foreman.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[tools]
22
rotrieve = { source = "roblox/rotriever", version = "0.5.4" }
3-
selene = { source = "Kampfkarren/selene", version = "0.18.2" }
3+
selene = { source = "Kampfkarren/selene", version = "0.20.0" }
44
stylua = { source = "JohnnyMorganz/StyLua", version = "=0.13.1" }

rotriever.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ LuauPolyfill = "github.com/roblox/luau-polyfill@0.3.4"
1111
LuauRegExp = "github.com/Roblox/luau-regexp@0.2.0"
1212
Chalk = "github.com/roblox/chalk-lua@0.1.3"
1313
Promise = "github.com/evaera/roblox-lua-promise@4.0.0"
14+
JestCore = { git = "https://github.com/roblox/jest-roblox.git", rev="master", package="JestCore" }
1415
JestGetType = { git = "https://github.com/roblox/jest-roblox.git", rev="master", package="JestGetType"}
1516
PrettyFormat = { git = "https://github.com/roblox/jest-roblox.git", rev="master", package="PrettyFormat"}
1617
RobloxShared = { git = "https://github.com/roblox/jest-roblox.git", rev="master", package="RobloxShared"}
17-
JestGlobals = { git = "https://github.com/roblox/jest-roblox.git", rev="master" }
18+
JestGlobals = { git = "https://github.com/roblox/jest-roblox.git", rev="master" }

selene.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
std = "roblox+testez"
1+
std = "roblox"
22

33
[config]
44
empty_if = { comments_count = true }

src/__tests__/config.spec.lua

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,62 @@
11
-- ROBLOX upstream: https://github.com/testing-library/dom-testing-library/blob/v8.14.0/src/__tests__/config.js
2-
return function()
3-
local Packages = script.Parent.Parent.Parent
42

5-
local JestGlobals = require(Packages.JestGlobals)
6-
local jestExpect = JestGlobals.expect
3+
local Packages = script.Parent.Parent.Parent
74

8-
local configModule = require(script.Parent.Parent.config)
9-
local configure = configModule.configure
10-
local getConfig = configModule.getConfig
5+
local JestGlobals = require(Packages.JestGlobals)
6+
local expect = JestGlobals.expect
7+
local test = JestGlobals.test
8+
local describe = JestGlobals.describe
9+
local beforeEach = JestGlobals.beforeEach
10+
local afterEach = JestGlobals.afterEach
1111

12-
describe("configuration API", function()
13-
local originalConfig
14-
beforeEach(function()
15-
-- Grab the existing configuration so we can restore
16-
-- it at the end of the test
17-
configure(function(existingConfig)
18-
originalConfig = existingConfig -- Don't change the existing config
19-
return {}
20-
end)
12+
local configModule = require(script.Parent.Parent.config)
13+
local configure = configModule.configure
14+
local getConfig = configModule.getConfig
15+
16+
describe("configuration API", function()
17+
local originalConfig
18+
beforeEach(function()
19+
-- Grab the existing configuration so we can restore
20+
-- it at the end of the test
21+
configure(function(existingConfig)
22+
originalConfig = existingConfig -- Don't change the existing config
23+
return {}
2124
end)
22-
afterEach(function()
23-
configure(originalConfig)
25+
end)
26+
afterEach(function()
27+
configure(originalConfig)
28+
end)
29+
beforeEach(function()
30+
configure({ other = 123 })
31+
end)
32+
describe("getConfig", function()
33+
test("returns existing configuration", function()
34+
local conf = getConfig()
35+
expect(conf.testIdAttribute).toEqual("data-testid")
2436
end)
25-
beforeEach(function()
26-
configure({ other = 123 })
37+
end)
38+
describe("configure", function()
39+
test("merges a delta rather than replacing the whole config", function()
40+
local conf = getConfig()
41+
expect(conf).toMatchObject({ testIdAttribute = "data-testid" })
2742
end)
28-
describe("getConfig", function()
29-
it("returns existing configuration", function()
30-
local conf = getConfig()
31-
jestExpect(conf.testIdAttribute).toEqual("data-testid")
32-
end)
43+
test("overrides existing values", function()
44+
configure({ testIdAttribute = "new-id" })
45+
local conf = getConfig()
46+
expect(conf.testIdAttribute).toEqual("new-id")
3347
end)
34-
describe("configure", function()
35-
it("merges a delta rather than replacing the whole config", function()
36-
local conf = getConfig()
37-
jestExpect(conf).toMatchObject({ testIdAttribute = "data-testid" })
38-
end)
39-
it("overrides existing values", function()
40-
configure({ testIdAttribute = "new-id" })
41-
local conf = getConfig()
42-
jestExpect(conf.testIdAttribute).toEqual("new-id")
43-
end)
44-
it("passes existing config out to config function", function()
45-
-- Create a new config key based on the value of an existing one
46-
configure(function(existingConfig)
47-
return {
48-
testIdAttribute = ("%s-derived"):format(tostring(existingConfig.testIdAttribute)),
49-
}
50-
end)
51-
local conf = getConfig() -- The new value should be there, and existing values should be
52-
-- untouched
53-
jestExpect(conf).toMatchObject({ testIdAttribute = "data-testid-derived" })
48+
test("passes existing config out to config function", function()
49+
-- Create a new config key based on the value of an existing one
50+
configure(function(existingConfig)
51+
return {
52+
testIdAttribute = ("%s-derived"):format(tostring(existingConfig.testIdAttribute)),
53+
}
5454
end)
55+
local conf = getConfig() -- The new value should be there, and existing values should be
56+
-- untouched
57+
expect(conf).toMatchObject({ testIdAttribute = "data-testid-derived" })
5558
end)
5659
end)
57-
end
60+
end)
61+
62+
return {}

0 commit comments

Comments
 (0)