Skip to content

Commit 19f17ba

Browse files
committed
improve get info
1 parent 28f7837 commit 19f17ba

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

lib/command/info.js

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,56 @@ const { getConfig, getTestRoot } = require('./utils')
44
const Codecept = require('../codecept')
55
const output = require('../output')
66

7+
async function getInstalledBrowsers() {
8+
try {
9+
const playwright = require('playwright')
10+
const browsers = await Promise.all(
11+
['chromium', 'firefox', 'webkit'].map(async browser => {
12+
try {
13+
const browserInstance = await playwright[browser].launch()
14+
const version = await browserInstance.version()
15+
await browserInstance.close()
16+
return `${browser}: ${version}`
17+
} catch (err) {
18+
return `${browser}: not installed`
19+
}
20+
}),
21+
)
22+
return browsers.join(`, `)
23+
} catch (err) {
24+
return 'Playwright not installed'
25+
}
26+
}
27+
28+
async function getOsBrowsers() {
29+
const chromeInfo = await envinfo.helpers.getChromeInfo()
30+
const edgeInfo = await envinfo.helpers.getEdgeInfo()
31+
const firefoxInfo = await envinfo.helpers.getFirefoxInfo()
32+
const safariInfo = await envinfo.helpers.getSafariInfo()
33+
34+
return [
35+
`chrome: ${chromeInfo ? chromeInfo[1] : 'not installed'}`,
36+
`edge: ${edgeInfo ? edgeInfo[1] : 'not installed'}`,
37+
`firefox: ${firefoxInfo ? firefoxInfo[1] : 'not installed'}`,
38+
`safari: ${safariInfo ? safariInfo[1] : 'not installed'}`,
39+
].join(', ')
40+
}
41+
742
module.exports = async function (path) {
843
const testsPath = getTestRoot(path)
944
const config = getConfig(testsPath)
1045
const codecept = new Codecept(config, {})
1146
codecept.init(testsPath)
1247

13-
output.print('\n Environment information:-\n')
48+
output.print('\n Environment information: \n')
1449
const info = {}
1550
info.codeceptVersion = Codecept.version()
1651
info.nodeInfo = await envinfo.helpers.getNodeInfo()
1752
info.osInfo = await envinfo.helpers.getOSInfo()
1853
info.cpuInfo = await envinfo.helpers.getCPUInfo()
19-
info.chromeInfo = await envinfo.helpers.getChromeInfo()
20-
info.edgeInfo = await envinfo.helpers.getEdgeInfo()
21-
info.firefoxInfo = await envinfo.helpers.getFirefoxInfo()
22-
info.safariInfo = await envinfo.helpers.getSafariInfo()
54+
info.osBrowsers = await getOsBrowsers()
55+
info.playwrightBrowsers = await getInstalledBrowsers()
56+
2357
const { helpers, plugins } = config
2458
info.helpers = helpers || "You don't use any helpers"
2559
info.plugins = plugins || "You don't have any enabled plugins"
@@ -47,6 +81,7 @@ module.exports.getMachineInfo = async () => {
4781
edgeInfo: await envinfo.helpers.getEdgeInfo(),
4882
firefoxInfo: await envinfo.helpers.getFirefoxInfo(),
4983
safariInfo: await envinfo.helpers.getSafariInfo(),
84+
playwrightBrowsers: await getInstalledBrowsers(),
5085
}
5186

5287
output.print('***************************************')

0 commit comments

Comments
 (0)