Skip to content Skip to sidebar Skip to footer

Imports In Vanilla/pure Js Testing With Protractor And Relative Paths

Until now, I was testing my non-Angular website (I only have JS, no node, not even ES6) using Jasmine, Karma and Travis CI. I am now trying to write functional tests (in case my v

Solution 1:

I'm not sure, is it Node.js related syntax, but as for import/export you can either use export/require like this

exportlet EXCEPTIONS = {
---- your code ----
}
constEXCEPTIONS = require(pathToExceptionsFile)

describe('The main page', function () {
    ---- Test code here ---
    expect(element(by.className('ajs-content')).getText()).toEqual(newEXCEPTIONS.NoParametersDetectedInURI().description);
})

or like this

letEXCEPTIONS= {
---- your code ----
}

module.exports = EXCEPTIONS
constEXCEPTIONS = require(pathToExceptionsFile)

describe('The main page', function () {
    ---- Test code here ---
    expect(element(by.className('ajs-content')).getText()).toEqual(newEXCEPTIONS.NoParametersDetectedInURI().description);
})

I think it's should work in vanila JS as well. But as long as you using Protractor, you already use Node.js, so i think it should work anyway.

Post a Comment for "Imports In Vanilla/pure Js Testing With Protractor And Relative Paths"