Skip to content

Bug: dynamicConfig doesn't work for multiple Helpers #1742

@VikalpP

Description

@VikalpP

What are you trying to achieve?

Use dynamic config for multiple Helpers.

What do you get instead?

Config didn't apply.

Provide console output if related. Use --verbose mode for more details.

Dynamic Config --
    Emitted | suite.before ([object Object])
    Error processing suite.before event:
    TypeError: Cannot read property 'options' of undefined
    at updateHelperConfig (/home/vikalp/Documents/CodeceptJS/lib/listener/config.js:18:52)                                                                                
    at EventEmitter.event.dispatcher.on (/home/vikalp/Documents/CodeceptJS/lib/listener/config.js:40:11)                                                                  
    at EventEmitter.emit (events.js:203:15)                                                                                                                               
    at Object.emit (/home/vikalp/Documents/CodeceptJS/lib/event.js:49:28)                                                                                                 
    at injectHook (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:167:11)                                                                                              
    at injectHook (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:8:5)                                                                                                 
    at Object.module.exports.suiteSetup (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:165:10)                                                                        
    at Context.suite.beforeAll (/home/vikalp/Documents/CodeceptJS/lib/ui.js:100:64)                                                                                       
    at callFn (/home/vikalp/Documents/CodeceptJS/node_modules/mocha/lib/runnable.js:354:21)                                                                               
    at Hook.Runnable.run (/home/vikalp/Documents/CodeceptJS/node_modules/mocha/lib/runnable.js:346:7)                                                                     
  change config 1 @WebDriverIO @Puppeteer @Protractor @Nightmare
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I dont see in current url "github.com")
    Emitted | step.after (I dont see in current url "github.com")
    Emitted | step.before (I see in current url "google.com")
    Emitted | step.after (I see in current url "google.com")
    Emitted | step.start (I am on page "/")
    I am on page "/"
    › [Url] http://localhost:8000/
    › [Browser:Error] Failed to load resource: the server responded with a status of 404 (Not Found)
    Emitted | step.passed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    Emitted | step.start (I dont see in current url "github.com")
    I dont see in current url "github.com"
    Emitted | step.passed (I dont see in current url "github.com")
    Emitted | step.finish (I dont see in current url "github.com")
    Emitted | step.start (I see in current url "google.com")
    I see in current url "google.com"
    [1] Error | Error
    Emitted | step.failed (I see in current url "google.com")
    Emitted | step.finish (I see in current url "google.com")
    [1] Error | Error
    [1] Starting <teardown> session
    Emitted | test.failed ([object Object])
    Emitted | test.finish ([object Object])
    [1] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, saving screenshot
 › Screenshot is saving to /home/vikalp/Documents/CodeceptJS/test/acceptance/output/change_config_1_@WebDriverIO_@Puppeteer_@Protractor_@Nightmare.failed.png
  ✖ FAILED in 826ms

    [2] Starting recording promises
    Emitted | test.after ([object Object])
  change config 2 @WebDriverIO @Puppeteer @Protractor @Nightmare
    Emitted | test.before ([object Object])
    Error processing test.before event:
    TypeError: Cannot read property 'options' of undefined
    at updateHelperConfig (/home/vikalp/Documents/CodeceptJS/lib/listener/config.js:18:52)                                                                                
    at EventEmitter.event.dispatcher.on (/home/vikalp/Documents/CodeceptJS/lib/listener/config.js:40:11)                                                                  
    at EventEmitter.emit (events.js:203:15)                                                                                                                               
    at Object.emit (/home/vikalp/Documents/CodeceptJS/lib/event.js:49:28)                                                                                                 
    at injectHook (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:153:11)                                                                                              
    at injectHook (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:8:5)                                                                                                 
    at Object.module.exports.setup (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:151:10)                                                                             
    at Context.suite.beforeEach (/home/vikalp/Documents/CodeceptJS/lib/ui.js:97:60)                                                                                       
    at callFn (/home/vikalp/Documents/CodeceptJS/node_modules/mocha/lib/runnable.js:354:21)                                                                               
    at Hook.Runnable.run (/home/vikalp/Documents/CodeceptJS/node_modules/mocha/lib/runnable.js:346:7)                                                                     
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I see in current url "github.com")
    Emitted | step.after (I see in current url "github.com")
    Emitted | step.start (I am on page "/")
    I am on page "/"
    [2] Error | TypeError: Cannot read property 'goto' of null
    Emitted | step.failed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    [2] Error | TypeError: Cannot read property 'goto' of null
    Emitted | step.failed (I see in current url "github.com")
    Emitted | step.finish (I see in current url "github.com")
    [2] Error | TypeError: Cannot read property 'goto' of null
    [2] Starting <teardown> session
    Emitted | test.failed ([object Object])
    Emitted | test.finish ([object Object])
    [2] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, saving screenshot
 › Screenshot is saving to /home/vikalp/Documents/CodeceptJS/test/acceptance/output/change_config_2_@WebDriverIO_@Puppeteer_@Protractor_@Nightmare.failed.png
    [2] <teardown> Error | TypeError: Cannot read property 'mainFrame' of null
TypeError: Cannot read property 'mainFrame' of null
  ✖ FAILED in 5ms

    [3] Starting recording promises
    Emitted | test.after ([object Object])
  change config 3 @WebDriverIO @Puppeteer @Protractor @Nightmare
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I dont see in current url "github.com")
    Emitted | step.after (I dont see in current url "github.com")
    Emitted | step.before (I see in current url "google.com")
    Emitted | step.after (I see in current url "google.com")
    Emitted | step.start (I am on page "/")
    I am on page "/"
    › [Url] http://localhost:8000/
    › [Browser:Error] Failed to load resource: the server responded with a status of 404 (Not Found)
    Emitted | step.passed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    Emitted | step.start (I dont see in current url "github.com")
    I dont see in current url "github.com"
    Emitted | step.passed (I dont see in current url "github.com")
    Emitted | step.finish (I dont see in current url "github.com")
    Emitted | step.start (I see in current url "google.com")
    I see in current url "google.com"
    [3] Error | Error
    Emitted | step.failed (I see in current url "google.com")
    Emitted | step.finish (I see in current url "google.com")
    [3] Error | Error
    [3] Starting <teardown> session
    Emitted | test.failed ([object Object])
    Emitted | test.finish ([object Object])
    [3] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, saving screenshot
 › Screenshot is saving to /home/vikalp/Documents/CodeceptJS/test/acceptance/output/change_config_3_@WebDriverIO_@Puppeteer_@Protractor_@Nightmare.failed.png
  ✖ FAILED in 593ms

    [4] Starting recording promises
    Emitted | test.after ([object Object])
  change config 4 @WebDriverIO @Puppeteer @Protractor @Nightmare
    Emitted | test.before ([object Object])
    Error processing test.before event:
    TypeError: Cannot read property 'options' of undefined
    at updateHelperConfig (/home/vikalp/Documents/CodeceptJS/lib/listener/config.js:18:52)                                                                                
    at EventEmitter.event.dispatcher.on (/home/vikalp/Documents/CodeceptJS/lib/listener/config.js:40:11)                                                                  
    at EventEmitter.emit (events.js:203:15)                                                                                                                               
    at Object.emit (/home/vikalp/Documents/CodeceptJS/lib/event.js:49:28)                                                                                                 
    at injectHook (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:153:11)                                                                                              
    at injectHook (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:8:5)                                                                                                 
    at Object.module.exports.setup (/home/vikalp/Documents/CodeceptJS/lib/scenario.js:151:10)                                                                             
    at Context.suite.beforeEach (/home/vikalp/Documents/CodeceptJS/lib/ui.js:97:60)                                                                                       
    at callFn (/home/vikalp/Documents/CodeceptJS/node_modules/mocha/lib/runnable.js:354:21)                                                                               
    at Hook.Runnable.run (/home/vikalp/Documents/CodeceptJS/node_modules/mocha/lib/runnable.js:346:7)                                                                     
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I see in current url "codecept.io")
    Emitted | step.after (I see in current url "codecept.io")
    Emitted | step.start (I am on page "/")
    I am on page "/"
    [4] Error | TypeError: Cannot read property 'goto' of null
    Emitted | step.failed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    [4] Error | TypeError: Cannot read property 'goto' of null
    Emitted | step.failed (I see in current url "codecept.io")
    Emitted | step.finish (I see in current url "codecept.io")
    [4] Error | TypeError: Cannot read property 'goto' of null
    [4] Starting <teardown> session
    Emitted | test.failed ([object Object])
    Emitted | test.finish ([object Object])
    [4] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, saving screenshot
 › Screenshot is saving to /home/vikalp/Documents/CodeceptJS/test/acceptance/output/change_config_4_@WebDriverIO_@Puppeteer_@Protractor_@Nightmare.failed.png
    [4] <teardown> Error | TypeError: Cannot read property 'mainFrame' of null
TypeError: Cannot read property 'mainFrame' of null
  ✖ FAILED in 4ms

    [5] Starting recording promises
    Emitted | test.after ([object Object])
  change config 5 @WebDriverIO @Puppeteer @Protractor @Nightmare
    Emitted | test.before ([object Object])
    Emitted | test.start ([object Object])
    Emitted | step.before (I am on page "/")
    Emitted | step.after (I am on page "/")
    Emitted | step.before (I dont see in current url "github.com")
    Emitted | step.after (I dont see in current url "github.com")
    Emitted | step.before (I see in current url "google.com")
    Emitted | step.after (I see in current url "google.com")
    Emitted | step.start (I am on page "/")
    I am on page "/"
    › [Url] http://localhost:8000/
    › [Browser:Error] Failed to load resource: the server responded with a status of 404 (Not Found)
    Emitted | step.passed (I am on page "/")
    Emitted | step.finish (I am on page "/")
    Emitted | step.start (I dont see in current url "github.com")
    I dont see in current url "github.com"
    Emitted | step.passed (I dont see in current url "github.com")
    Emitted | step.finish (I dont see in current url "github.com")
    Emitted | step.start (I see in current url "google.com")
    I see in current url "google.com"
    [5] Error | Error
    Emitted | step.failed (I see in current url "google.com")
    Emitted | step.finish (I see in current url "google.com")
    [5] Error | Error
    [5] Starting <teardown> session
    Emitted | test.failed ([object Object])
    Emitted | test.finish ([object Object])
    [5] <teardown> Stopping recording promises
 › <screenshotOnFail> Test failed, saving screenshot
 › Screenshot is saving to /home/vikalp/Documents/CodeceptJS/test/acceptance/output/change_config_5_@WebDriverIO_@Puppeteer_@Protractor_@Nightmare.failed.png
  ✖ FAILED in 822ms

    [6] Starting recording promises
    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

Provide test source code if related

Feature('Dynamic Config').config({ url: 'https://google.com' });

Scenario('change config 1 @WebDriverIO @Puppeteer @Protractor @Nightmare', (I) => {
  I.amOnPage('/');
  I.dontSeeInCurrentUrl('github.com');
  I.seeInCurrentUrl('google.com');
});

Scenario('change config 2 @WebDriverIO @Puppeteer @Protractor @Nightmare', (I) => {
  I.amOnPage('/');
  I.seeInCurrentUrl('github.com');
}).config({ url: 'https://github.com' });

Scenario('change config 3 @WebDriverIO @Puppeteer @Protractor @Nightmare', (I) => {
  I.amOnPage('/');
  I.dontSeeInCurrentUrl('github.com');
  I.seeInCurrentUrl('google.com');
});

Scenario('change config 4 @WebDriverIO @Puppeteer @Protractor @Nightmare', (I) => {
  I.amOnPage('/');
  I.seeInCurrentUrl('codecept.io');
}).config((test) => {
  return { url: 'https://codecept.io/', capabilities: { 'moz:title': test.title } };
});

Scenario('change config 5 @WebDriverIO @Puppeteer @Protractor @Nightmare', (I) => {
  I.amOnPage('/');
  I.dontSeeInCurrentUrl('github.com');
  I.seeInCurrentUrl('google.com');
});

Details

  • CodeceptJS version: 2.1.5
  • NodeJS Version: 10.16.0
  • Operating System: Ubuntu (Linux)
  • Puppeteer: 1.15.0
  • Configuration file:
// File: /test/acceptance/codecept.Puppeteer.js
const TestHelper = require('../support/TestHelper');

module.exports.config = {
  tests: './*_test.js',
  timeout: 10000,
  output: './output',
  helpers: {
    Puppeteer: {
      url: TestHelper.siteUrl(),
      show: true,
      chrome: {
        args: [
          '--no-sandbox',
          '--disable-setuid-sandbox',
        ],
      },
    },
    Polly: {
      url: TestHelper.siteUrl(),
    },
  },
  include: {},
  bootstrap: false,
  mocha: {},
  name: 'acceptance',
  gherkin: {
    features: './gherkin/*.feature',
    steps: ['./gherkin/steps.js'],
  },
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions