I have a file /test/email/email.js
:
export default class verificationEmail {
constructor() {
var Imap = require('imap'),
inspect = require('util').inspect
var imap = new Imap({
user: 'wdio@example.com',
password: 'password',
host: 'imap.gmail.com',
port: 993,
tls: true
})
}
openInbox(cb) {
imap.openBox('INBOX', true, cb)
}
checkEmail() {
(code copied from node-imap)
and this file is called in a webdriver test file:
import verificationEmail from '../email/email';
then called:
await(verificationEmail.checkEmail())
The terminal produces an error:
_email.default.checkEmail is not a function
- Why does this error prefix
email
with an underscore? - Why is
checkEmail
not working?
Help appreciated.
Edit
The code is now:
const verificationEmail1 = new verificationEmail()
await verificationEmail1.checkEmail()
but the same error occurs:
_email.default.checkEmail is not a function
Edit
This is babel.config.js
:
module.exports = {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "14"
}
}
]
]
}
This is wdio.conf.js
:
const { join } = require('path')
exports.config = {
specs: [
// './test/specs/**/testing.spec.js',
// './test/specs/**/studiofile.spec.js',
// './test/specs/**/businessSettings.spec.js',
// './test/specs/**/manage.spec.js',
// './test/specs/**/sandbox.spec.js',
'./test/specs/**/sandbox-restaurant-onboarding.spec.js',
],
maxInstances: 10,
capabilities: [
{
maxInstances: 6,
browserName: 'chrome',
acceptInsecureCerts: true
},
],
logLevel: 'error',
bail: 0,
baseUrl: 'https://testing.mandoemedia.com',
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: [['chromedriver'],
['image-comparison',
{
baselineFolder: join(process.cwd(), './tests/visualRegressionBaseline/'),
formatImageName: '{tag}-{logName}',
screenshotPath: join(process.cwd(), './tests/visualRegressionDiff/'),
autoSaveBaseline: true,
blockOutStatusBar: true,
blockOutToolBar: true,
clearRuntimeFolder: true,
disableCSSAnimation: true
}]
],
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 6000000000
},
beforeTest: function (test, context) {
browser.maximizeWindow();
},
afterTest: function(test, context, { error, result, duration, passed, retries }) {
if (error) {
browser.takeScreenshot();
}
},
}