Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions lib/command/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,56 @@ const { getConfig, getTestRoot } = require('./utils')
const Codecept = require('../codecept')
const output = require('../output')

async function getInstalledBrowsers() {
try {
const playwright = require('playwright')
const browsers = await Promise.all(
['chromium', 'firefox', 'webkit'].map(async browser => {
try {
const browserInstance = await playwright[browser].launch()
const version = await browserInstance.version()
await browserInstance.close()
return `${browser}: ${version}`
} catch (err) {
return `${browser}: not installed`
}
}),
)
return browsers.join(`, `)
} catch (err) {
return 'Playwright not installed'
}
}

async function getOsBrowsers() {
const chromeInfo = await envinfo.helpers.getChromeInfo()
const edgeInfo = await envinfo.helpers.getEdgeInfo()
const firefoxInfo = await envinfo.helpers.getFirefoxInfo()
const safariInfo = await envinfo.helpers.getSafariInfo()

return [
`chrome: ${chromeInfo ? chromeInfo[1] : 'not installed'}`,
`edge: ${edgeInfo ? edgeInfo[1] : 'not installed'}`,
`firefox: ${firefoxInfo ? firefoxInfo[1] : 'not installed'}`,
`safari: ${safariInfo ? safariInfo[1] : 'not installed'}`,
].join(', ')
}

module.exports = async function (path) {
const testsPath = getTestRoot(path)
const config = getConfig(testsPath)
const codecept = new Codecept(config, {})
codecept.init(testsPath)

output.print('\n Environment information:-\n')
output.print('\n Environment information: \n')
const info = {}
info.codeceptVersion = Codecept.version()
info.nodeInfo = await envinfo.helpers.getNodeInfo()
info.osInfo = await envinfo.helpers.getOSInfo()
info.cpuInfo = await envinfo.helpers.getCPUInfo()
info.chromeInfo = await envinfo.helpers.getChromeInfo()
info.edgeInfo = await envinfo.helpers.getEdgeInfo()
info.firefoxInfo = await envinfo.helpers.getFirefoxInfo()
info.safariInfo = await envinfo.helpers.getSafariInfo()
info.osBrowsers = await getOsBrowsers()
info.playwrightBrowsers = await getInstalledBrowsers()

const { helpers, plugins } = config
info.helpers = helpers || "You don't use any helpers"
info.plugins = plugins || "You don't have any enabled plugins"
Expand Down Expand Up @@ -47,6 +81,7 @@ module.exports.getMachineInfo = async () => {
edgeInfo: await envinfo.helpers.getEdgeInfo(),
firefoxInfo: await envinfo.helpers.getFirefoxInfo(),
safariInfo: await envinfo.helpers.getSafariInfo(),
playwrightBrowsers: await getInstalledBrowsers(),
}

output.print('***************************************')
Expand Down
Loading