• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / jestronaut / 12214239123

07 Dec 2024 04:01PM UTC coverage: 72.291%. First build
12214239123

Pull #13

github

web-flow
Merge e4c588db6 into 98f7720fe
Pull Request #13: Async support (🚧WIP)

386 of 511 new or added lines in 13 files covered. (75.54%)

1568 of 2169 relevant lines covered (72.29%)

3855.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.37
/libs/jestronaut.lua
1
local optionsLib = require "jestronaut/environment/options"
×
2
local describeLib = require "jestronaut/environment/describe"
×
3
local environmentLib = require "jestronaut/environment"
×
4
local coverageLib = require "jestronaut/coverage"
×
5
local expectLib = require "jestronaut/expect"
×
6
local mockLib = require "jestronaut/mock"
×
7
local setupModuleMocking = mockLib.setupModuleMocking
×
8

9
setupModuleMocking()
×
10

11
--- @class Jestronaut
12
local JESTRONAUT = {
×
13
    runnerOptions = {},
14
}
15

16
--- @param runnerOptions RunnerOptions
17
--- @return Jestronaut
18
function JESTRONAUT:configure(runnerOptions)
×
19
    environmentLib.resetEnvironment()
×
20

21
    -- Setup the root describe where every other describe and test will be nested under
NEW
22
    describeLib.describeTransparent("root", function() end)
×
23

24
    runnerOptions = optionsLib.merge(runnerOptions)
×
25

26
    self.runnerOptions = runnerOptions
×
27

28
    if not runnerOptions.roots then
×
29
        error(
×
30
        "No roots found in config. Provide at least one root that points to a directory where tests will be run from.")
×
31
    end
32

33
    environmentLib.setRoots(runnerOptions.roots)
×
34

35
    if runnerOptions.coverage == true then
×
36
        coverageLib.setupCoverage(runnerOptions.roots, runnerOptions.coverageDirectory, runnerOptions.coverageProvider)
×
37
    end
38

39
    return self
4✔
40
end
41

42
--- Registers the tests. This is done by calling the given function.
43
--- @param testRegistrar function
44
--- @return Jestronaut
45
function JESTRONAUT:registerTests(testRegistrar)
×
46
    if not self.runnerOptions then
4✔
47
        error(
×
48
        "No options found. You must setup jestronaut (with jestronaut:configure(options)) before registering tests.")
×
49
    end
50

51
    environmentLib.registerTests(testRegistrar)
4✔
52

53
    return self
4✔
54
end
55

56
--- Runs the tests.
57
--- @return Jestronaut
NEW
58
function JESTRONAUT:runTests()
×
59
    if not self.runnerOptions then
4✔
60
        error("No options found. You must setup jestronaut (with jestronaut:configure(options)) before running tests.")
×
61
    end
62

63
    environmentLib.runTests(self.runnerOptions)
4✔
64

65
    return self
4✔
66
end
67

68
function JESTRONAUT:retryTimes(numRetries, options)
×
69
    environmentLib.retryTimes(numRetries, options)
12✔
70
end
71

72
function JESTRONAUT:setTimeout(timeout)
×
73
    environmentLib.setTimeout(timeout)
4✔
74
end
75

76
function JESTRONAUT:getGlobals()
×
77
    local globals = {}
×
78

79
    expectLib.exposeTo(globals)
×
80
    environmentLib.exposeTo(globals)
×
81

82
    globals.jestronaut = self
×
83

84
    mockLib.exposeTo(globals.jestronaut)
×
85

86
    return globals
×
87
end
88

89
function JESTRONAUT:withGlobals()
×
90
    local globals = self:getGlobals()
×
91

92
    for key, value in pairs(globals) do
×
93
        _G[key] = value
×
94
    end
95
end
96

97
package.loaded['@jestronaut_globals'] = JESTRONAUT:getGlobals()
×
98

99
return JESTRONAUT
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc