I am in the process of transitioning a functional JavaScript project to TypeScript. The project incorporates nightwatch.js
Below is my primary test class:
declare function require(path: string): any;
import * as dotenv from "dotenv";
import signinPage = require("../built/pages/signinPage.js");
import instancesPage = require("../built/pages/instancesPage.js");
dotenv.config();
module.exports = {
'User can sign in'(client) {
console.log("Sign in as email: " + process.env.EMAIL);
signinPage
// .navigate()
.signin(process.env.EMAIL, process.env.PASSWORD);
// allow time for loading
client.pause(5000);
instancesPage.expect.element('@homepageWelcomeTitle').text.to.contain('Welcome to the CJDocs Home!');
client.end();
}
}
Here is the pageObject that contains the problematic function:
module.exports = {
signin: function(email, password) {
return this
.waitForElementVisible('@emailInput')
.setValue('@emailInput', email)
.setValue('@passwordInput', password)
.waitForElementVisible('@signinButton')
.click('@signinButton')
},
elements: {
emailInput: {
selector: 'input[type=email]'
},
passwordInput: {
selector: 'input[name=password]'
},
signinButton: {
selector: 'button[type=submit]'
}
}
};
Upon running this (via terminal using NPM test), I encounter an error:
TypeError: signinPage.signin is not a function
It appears that signinPage.signin does exist as a function.
What could be causing the function to not be recognized?