Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
: [],
modulePaths: parseModulePath(path.join(__dirname, '../node_modules')),
setupFilesAfterEnv: [
require.resolve('jest-environment-selenium/dist/setup.js'),
],
testEnvironment: 'jest-environment-selenium',
testEnvironmentOptions: configuration,
},
dependencies: project.dependencies || {},
},
null,
2
)
)
return Selianize(project, { silenceErrors: true }, project.snapshot).then(
code => {
const tests = code.tests
.reduce((tests, test) => {
return (tests += test.code)
}, 'const utils = require("./utils.js");const tests = {};')
.concat('module.exports = tests;')
writeJSFile(path.join(projectPath, 'commons'), tests, '.js')
writeJSFile(path.join(projectPath, 'utils'), getUtilsFile(), '.js')
code.suites.forEach(suite => {
if (!suite.tests) {
// not parallel
const cleanup = suite.persistSession
? ''
: 'beforeEach(() => {vars = {};});afterEach(async () => (cleanup()));'
writeJSFile(
path.join(projectPath, sanitizeFileName(suite.name)),
code => {
const tests = code.tests
.reduce((tests, test) => {
return (tests += test.code)
}, 'const utils = require("./utils.js");const tests = {};')
.concat('module.exports = tests;')
writeJSFile(path.join(projectPath, 'commons'), tests, '.js')
writeJSFile(path.join(projectPath, 'utils'), getUtilsFile(), '.js')
code.suites.forEach(suite => {
if (!suite.tests) {
// not parallel
const cleanup = suite.persistSession
? ''
: 'beforeEach(() => {vars = {};});afterEach(async () => (cleanup()));'
writeJSFile(
path.join(projectPath, sanitizeFileName(suite.name)),
`// This file was generated using Selenium IDE\nconst tests = require("./commons.js");${
code.globalConfig
}${suite.code}${cleanup}`
)
} else if (suite.tests.length) {
fs.mkdirSync(path.join(projectPath, sanitizeFileName(suite.name)))
// parallel suite
suite.tests.forEach(test => {
router.get('/location', (req, res) => {
Location.emit(req.location).then(res)
})
return Manager.validatePluginExport(project).then(() => {
return Selianize(project, { silenceErrors: true, skipStdLibEmitting: true }).catch(err => {
const markdown = ParseError(err && err.message || err);
ModalState.showAlert({
title: "Error saving project",
description: markdown,
confirmLabel: "Download log",
cancelLabel: "Close"
}, (choseDownload) => {
if (choseDownload) {
browser.downloads.download({
filename: project.name + "-logs.md",
url: createBlob("text/markdown", markdown),
saveAs: true,
conflictAction: "overwrite"
});
}
});
return Manager.validatePluginExport(project).then(() => {
return Selianize(project, {
silenceErrors: true,
skipStdLibEmitting: true,
}).catch(err => {
const markdown = ParseError((err && err.message) || err)
ModalState.showAlert({
title: 'Error saving project',
description: markdown,
confirmLabel: 'download log',
cancelLabel: 'close',
}).then(choseDownload => {
if (choseDownload) {
browser.downloads.download({
filename: project.name + '-logs.md',
url: createBlob('text/markdown', markdown),
saveAs: true,
conflictAction: 'overwrite',
}).catch(err => {
const markdown = ParseError((err && err.message) || err)
ModalState.showAlert({
title: 'Error saving project',
description: markdown,
confirmLabel: 'download log',
cancelLabel: 'close',
}).then(choseDownload => {
if (choseDownload) {
browser.downloads.download({
filename: project.name + '-logs.md',
url: createBlob('text/markdown', markdown),
saveAs: true,
conflictAction: 'overwrite',
})
}
})
return Promise.reject()
return Selianize(project, { silenceErrors: true, skipStdLibEmitting: true }).catch(err => {
const markdown = ParseError(err && err.message || err);
ModalState.showAlert({
title: "Error saving project",
description: markdown,
confirmLabel: "Download log",
cancelLabel: "Close"
}, (choseDownload) => {
if (choseDownload) {
browser.downloads.download({
filename: project.name + "-logs.md",
url: createBlob("text/markdown", markdown),
saveAs: true,
conflictAction: "overwrite"
});
}
});
return Promise.reject();
constructor() {
this.plugins = []
RegisterConfigurationHook(project => {
return new Promise(res => {
Promise.all(
this.plugins.map(plugin =>
this.emitConfiguration(plugin, project).catch(_e => {
return ''
})
)
).then(configs => res(configs.join('')))
})
})
}
plugin.commands.forEach(({ id, name, type, docs }) => {
const doks = this.useExistingArgTypesIfProvided(
Object.assign({}, docs, {
plugin: {
id,
},
})
)
Commands.addCommand(id, { name, type, ...doks })
registerCommand(id, RunCommand.bind(undefined, plugin.id, id))
RegisterEmitter(id, this.emitCommand.bind(undefined, plugin, id))
})
}
registerPlugin(plugin) {
if (!this.hasPlugin(plugin.id)) {
plugin.canEmit = false
this.plugins.push(plugin)
RegisterSuiteHook(this.emitSuite.bind(undefined, plugin))
RegisterTestHook(this.emitTest.bind(undefined, plugin))
if (plugin.commands) {
plugin.commands.forEach(({ id, name, type, docs }) => {
const doks = this.useExistingArgTypesIfProvided(
Object.assign({}, docs, {
plugin: {
id,
},
})
)
Commands.addCommand(id, { name, type, ...doks })
registerCommand(id, RunCommand.bind(undefined, plugin.id, id))
RegisterEmitter(id, this.emitCommand.bind(undefined, plugin, id))
})
}
} else {