Clear additional global state between unit test runs
Clears out some global state that was being left over between unit tests runs, causing indeterminate results when running multiple tests against data at the global scope.
This commit is contained in:
parent
0c17303436
commit
e34c23b64f
@ -674,10 +674,23 @@
|
||||
-- individual test runs.
|
||||
---
|
||||
|
||||
local numBuiltInGlobalBlocks
|
||||
|
||||
function api.reset()
|
||||
if numBuiltInGlobalBlocks == nil then
|
||||
numBuiltInGlobalBlocks = #api.scope.global.blocks
|
||||
end
|
||||
|
||||
for containerClass in p.container.eachChildClass(p.global) do
|
||||
api.scope.global[containerClass.pluralName] = {}
|
||||
end
|
||||
|
||||
api.scope.current = api.scope.global
|
||||
|
||||
local currentGlobalBlockCount = #api.scope.global.blocks
|
||||
for i = currentGlobalBlockCount, numBuiltInGlobalBlocks + 1, -1 do
|
||||
table.remove(api.scope.global.blocks, i)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user