-
-
Notifications
You must be signed in to change notification settings - Fork 750
Expand file tree
/
Copy pathinject.js
More file actions
29 lines (25 loc) · 741 Bytes
/
inject.js
File metadata and controls
29 lines (25 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const parser = require('../parser')
const getInjectedArguments = (fn, test) => {
const container = require('../container')
const testArgs = {}
const params = parser.getParams(fn) || []
const objects = container.support()
for (const key of params) {
testArgs[key] = {}
if (test && test.inject && test.inject[key]) {
// @FIX: need fix got inject
testArgs[key] = test.inject[key]
continue
}
if (!objects[key]) {
throw new Error(`Object of type ${key} is not defined in container`)
}
testArgs[key] = container.support(key)
}
if (test) {
testArgs.suite = test?.parent
testArgs.test = test
}
return testArgs
}
module.exports.getInjectedArguments = getInjectedArguments