I am using protractor/js for automating end to end tests for our website. We have a test data set that we have saved in different JS files and we use this data while executing test cases. We are using POM. So, generally the calls to data files are originated from the page files only.

So, here is the issue: We have started creating a suite for component tests which uses page files from the same suite as mentioned above. But the issue is that the component tests require different data for execution.

How can we achieve that when the regression tests are executing, then page files should use different set of data but when component tests are executing, they should use different sets of data. However, calls to the data files will be made from the page files which are common.

Let me know in case you need any more details

  • Please SHOW your current implementation in code to give clarity and highlight issue in code. Jan 20, 2019 at 10:26
  • I have edited title to make it specific, please feel free to revert back as needed. Jan 20, 2019 at 10:32

1 Answer 1


Simply store data in json object and iterate it over any function(page object) call:

describe('LoginPage.', function() {
    var loginPage = require('../PageObjects/LoginPage.js');
    var loginData = require('../TestData/json/loginData.json');

    loginData.forEach(function (data) {
        it(data.description, function () {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.