-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from Roblox/bbrimeyer/feature/additional-tests
Add missing end2end test cases
- Loading branch information
Showing
8 changed files
with
158 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
return function() | ||
describe("lower", function() | ||
beforeAll(function() | ||
expect.extend({ | ||
bar = function() | ||
return { | ||
message = "custom failure message (not)", | ||
pass = true, | ||
} | ||
end | ||
}) | ||
end) | ||
|
||
it("SHOULD run", function() | ||
print("foo-a") | ||
expect(0).foo(0) | ||
expect(0).bar(0) | ||
end) | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
return function() | ||
beforeAll(function() | ||
print("init.spec") | ||
expect.extend({ | ||
foo = function() | ||
return { | ||
message = "custom failure message (not)", | ||
pass = true, | ||
} | ||
end | ||
}) | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local TestEZ = require(script.Parent.Parent.TestEZ) | ||
|
||
local noOptReporter = { | ||
report = function() | ||
end, | ||
} | ||
|
||
return { | ||
["run expect-extend e2e"] = function() | ||
TestEZ.run(script:FindFirstChild("expect-extend"), function(results) | ||
assert(#results.errors == 0, | ||
"Expected no errors, got " .. tostring(results.errors[1]) .. | ||
" plus " .. tostring(#results.errors - 1) .. " more.") | ||
end) | ||
end, | ||
|
||
["run lifecycle e2e w/ filter for describe block"] = function() | ||
TestEZ.TestBootstrap:run({ | ||
script:FindFirstChild("lifecycle"):FindFirstChild("testNameFilterDescribeBlock"), | ||
}, | ||
noOptReporter, | ||
{ | ||
testNamePattern = "super specific describe block", | ||
}) | ||
end, | ||
|
||
["run lifecycle e2e w/ filter for file name"] = function() | ||
TestEZ.TestBootstrap:run({ | ||
script:FindFirstChild("lifecycle"):FindFirstChild("testNameFilterFileName"), | ||
}, | ||
noOptReporter, | ||
{ | ||
testNamePattern = "specificFileName", | ||
}) | ||
end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
-- Shared test cases asserting lifecycle hooks are firing in the correct order | ||
|
||
return function() | ||
describe("full example", function() | ||
beforeAll(function(context) | ||
context.globalState = {} | ||
|
||
table.insert(context.globalState, "beforeAll") | ||
expect(table.find(context.globalState, "beforeAll")).to.equal(1) | ||
end) | ||
|
||
beforeEach(function(context) | ||
table.insert(context.globalState, "beforeEach") | ||
expect(table.find(context.globalState, "beforeEach")).to.equal(2) | ||
end) | ||
|
||
it("it block", function(context) | ||
table.insert(context.globalState, "test") | ||
expect(table.find(context.globalState, "test")).to.equal(3) | ||
end) | ||
|
||
afterEach(function(context) | ||
table.insert(context.globalState, "afterEach") | ||
expect(table.find(context.globalState, "afterEach")).to.equal(4) | ||
end) | ||
|
||
afterAll(function(context) | ||
table.insert(context.globalState, "afterAll") | ||
expect(table.find(context.globalState, "afterAll")).to.equal(5) | ||
end) | ||
end) | ||
|
||
describe("no it block - should not call beforeEach or afterEach", function() | ||
beforeAll(function(context) | ||
context.globalState = {} | ||
|
||
table.insert(context.globalState, "beforeAll") | ||
expect(table.find(context.globalState, "beforeAll")).to.equal(1) | ||
end) | ||
|
||
beforeEach(function() | ||
fail("should not be called") | ||
end) | ||
|
||
afterEach(function() | ||
fail("should not be called") | ||
end) | ||
|
||
afterAll(function(context) | ||
table.insert(context.globalState, "afterAll") | ||
expect(table.find(context.globalState, "afterAll")).to.equal(2) | ||
end) | ||
end) | ||
end |
11 changes: 11 additions & 0 deletions
11
tests/e2e/lifecycle/testNameFilterDescribeBlock/specificDescribeName.spec.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
local completeLifecycleOrderTests = require(script:FindFirstAncestor("lifecycle").completeLifecycleOrderTests) | ||
|
||
return function() | ||
describe("never run", function() | ||
it("SHOULD FAIL", function() | ||
fail("This should have never ran. Check testNamePattern") | ||
end) | ||
end) | ||
|
||
describe("super specific describe block", completeLifecycleOrderTests) | ||
end |
5 changes: 5 additions & 0 deletions
5
tests/e2e/lifecycle/testNameFilterFileName/otherFileName.spec.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
return function() | ||
it("SHOULD NEVER RUN", function() | ||
fail("This should never have run in this file. Check testNamePattern.") | ||
end) | ||
end |
5 changes: 5 additions & 0 deletions
5
tests/e2e/lifecycle/testNameFilterFileName/specificFileName.spec.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local completeLifecycleOrderTests = require(script:FindFirstAncestor("lifecycle").completeLifecycleOrderTests) | ||
|
||
return function() | ||
describe("file name", completeLifecycleOrderTests) | ||
end |