(fn, { warnOnLegacyFormat = false } = {})
| 15 | } |
| 16 | |
| 17 | function getParams(fn, { warnOnLegacyFormat = false } = {}) { |
| 18 | if (fn.isSinonProxy) return [] |
| 19 | try { |
| 20 | const reflected = parser.parse(fn) |
| 21 | if (warnOnLegacyFormat && (reflected.args.length > 1 || reflected.args[0] === 'I')) { |
| 22 | output.error('Error: old CodeceptJS v2 format detected. Upgrade your project to the new format -> https://bit.ly/codecept3Up') |
| 23 | } |
| 24 | if (reflected.destructuredArgs.length > 0) reflected.args = [...reflected.destructuredArgs] |
| 25 | const params = reflected.args.map(p => { |
| 26 | const def = reflected.defaults[p] |
| 27 | if (def) { |
| 28 | return `${p}=${def}` |
| 29 | } |
| 30 | return p |
| 31 | }) |
| 32 | return params |
| 33 | } catch (err) { |
| 34 | console.log(`Error in ${fn.toString()}`) |
| 35 | output.error(err) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | export { getParams } |
| 40 |
no test coverage detected