I am writing a Node JS Test Suite that contains six tests. In each test I am passing a variable brand that equals an argument allowing me to pass in a cookie, it looks like this:
const Nightmare = require('nightmare')
const path = require('path')
const nightmare = Nightmare({ show: true })
var someTest = function(brand){
var brand = process.argv[2]
nightmare
.viewport(1300, 900)
.cookies.clear()
.cookies.set('brand', brand)
.wait('#auth-email')
.refresh()
.wait('#auth-email')
.screenshot(path.join(__dirname, new Date().getTime() + "3.png"))
.wait(2000)
.click('form[name=loginForm] [type=submit]')
.wait(2000)
.cookies.clear()
.end()
.then((res) => console.log('Successful'))
.catch((err) => console.error('Errror!'))
}
module.exports = someTest
I have a index.js file that runs all six of the tests when I execute it in my terminal using the command: node index.js brand(cookie), the index.js file looks like this:
someTest = require('./someTest.js')
someTest(process.argv[2]);
someTest2 = require('./someTest2.js')
someTest2(process.argv[2]);
In this index.js file I would like to be able to run an array of brands(cookies) instead of stating it in the command line like: node index.js brand(cookie), to look something like this:
var brand = ['cookie1', 'cookie2']
someTest = require('./someTest.js')
someTest(process.argv[2]);
someTest2 = require('./someTest2.js')
someTest2(process.argv[2]);
However, I am not sure how to process an array as an argument instead. Node is new to me and I am still learning, any insight is much appreciate. Thank you for the help :D
Aucun commentaire:
Enregistrer un commentaire