You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to test a whole signup functionality, the typical two steps signup, you need to fill small form, get an email with a link and fill the second big form with more personal data. I'm building a very very very custom command that connects to a gmail inbox, retrieves a message, extract the link to the second form and starts the test for the second form.
The code for my command is as follows:
exports.command = function(callback) {
var
self = this,
Imap = require("imap"),
MailParser = require("mailparser").MailParser,
inspect = require("util").inspect,
jsdom = require("jsdom");
var imap = new Imap({
user: 'XXXXXXXXXX',
password: 'XXXXXXXXXX',
host: 'imap.gmail.com',
port: 993,
tls: true,
tlsOptions: { rejectUnauthorized: false }
});
function openInbox(cb)
{
imap.openBox('INBOX', true, cb);
}
function getConfirmationMessage()
{
imap.once('ready',function(){
openInbox(function(err, box) {
if (err) throw err;
imap.search(['ALL',['FROM','no-reply@mdirector.com'],['SUBJECT','Activa tu cuenta de email marketing gratis']], function(err,results) {
if (err) throw err;
var fetch = imap.fetch(results, { bodies: '' });
fetch.on('message', function(msg) {
var mailparser = new MailParser({ defaultCharset: 'utf-8'});
mailparser.on("end", function(mail_obj) {
var html = mail_obj.html;
jsdom.env(html,["http://code.jquery.com/jquery.js"], function(errors,window) {
var hash_link = window.$('a').attr("href");
if(typeof callback === "function") {
callback.call(self,hash_link);
}
});
});
msg.on('body',function(stream,info) {
stream.on("data",function(chunk) {
mailparser.write(chunk.toString('utf-8'));
})
});
msg.on("end",function() {
mailparser.end();
});
});
fetch.once('error', function(err) {
console.log('Fetch error: ' + err);
});
fetch.once('end', function() {
imap.end();
});
});
});
});
imap.once('error', function(err) {
console.log(err);
});
imap.connect();
}
getConfirmationMessage();
return this;
}
Can I use the returned url in the callback to feed the browser.url and start a new test suite inside or outside the callback?
Besides this, I'm getting an error from nightwatch when I try to use the command, my command file is called checkImapInbox.js inside the mw_custom_commands directory, that is in my project root directory. I'm using a grunt task, via grunt-nightwatch to run my tests, my Gruntfile.js section for nightwatch looks like follow:
An error occured while running the test:
TypeError: Object #<Nightwatch> has no method 'checkImapInbox'
at Object.module.exports.MDirector - Signup - Step 2 (/home/diego/Code/mdirector.backend/tests/integration/frontend/signup-step1.js:22:14)
at clientFn (/home/diego/Code/mdirector.backend/node_modules/grunt-nightwatch/node_modules/nightwatch/runner/run.js:149:19)
at Object.setUp (/home/diego/Code/mdirector.backend/node_modules/grunt-nightwatch/node_modules/nightwatch/runner/run.js:52:35)
at /home/diego/Code/mdirector.backend/node_modules/grunt-nightwatch/node_modules/nightwatch/runner/run.js:152:13
at next [as _onTimeout] (/home/diego/Code/mdirector.backend/node_modules/grunt-nightwatch/node_modules/nightwatch/runner/run.js:103:11)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
Hope you can help me.
Thanks in advance.
Diego.
The text was updated successfully, but these errors were encountered:
Hi there,
I'm trying to test a whole signup functionality, the typical two steps signup, you need to fill small form, get an email with a link and fill the second big form with more personal data. I'm building a very very very custom command that connects to a gmail inbox, retrieves a message, extract the link to the second form and starts the test for the second form.
The code for my command is as follows:
and my test looks like this:
Can I use the returned url in the callback to feed the browser.url and start a new test suite inside or outside the callback?
Besides this, I'm getting an error from nightwatch when I try to use the command, my command file is called checkImapInbox.js inside the mw_custom_commands directory, that is in my project root directory. I'm using a grunt task, via grunt-nightwatch to run my tests, my Gruntfile.js section for nightwatch looks like follow:
and the error I'm getting from nightwatch is:
Hope you can help me.
Thanks in advance.
Diego.
The text was updated successfully, but these errors were encountered: