Skip to content

optimizely-sdk test suite has cross-test-file pollution #488

@jasonkarns

Description

@jasonkarns

While researching which file is causing the node process to hang during the test suite (#487 ), I ran each test file individually.

In doing so, I discovered that the lib/plugins/event_dispatcher/index.browser.tests.js test file does not pass successfully when run independently. That means it is dependent (accidentally) on some side effect that another test file is causing.

$ npx mocha -r esm -r lib/tests/exit_on_unhandled_rejection.js lib/plugins/event_dispatcher/index.browser.tests.js


  lib/plugins/event_dispatcher/browser
    APIs
      dispatchEvent
        1) should send a POST request with the specified params
        2) should execute the callback passed to event dispatcher with a post
        3) should execute the callback passed to event dispatcher with a get


  0 passing (10ms)
  3 failing

  1) lib/plugins/event_dispatcher/browser
       APIs
         dispatchEvent
           should send a POST request with the specified params:
     ReferenceError: XMLHttpRequest is not defined
      at dispatchEvent (lib/plugins/event_dispatcher/index.browser.js:31:5)
      at Context.<anonymous> (lib/plugins/event_dispatcher/index.browser.tests.js:50:9)
      at process.topLevelDomainCallback (domain.js:126:23)

  2) lib/plugins/event_dispatcher/browser
       APIs
         dispatchEvent
           should execute the callback passed to event dispatcher with a post:
     ReferenceError: XMLHttpRequest is not defined
      at dispatchEvent (lib/plugins/event_dispatcher/index.browser.js:31:5)
      at Context.<anonymous> (lib/plugins/event_dispatcher/index.browser.tests.js:69:9)
      at process.topLevelDomainCallback (domain.js:126:23)

  3) lib/plugins/event_dispatcher/browser
       APIs
         dispatchEvent
           should execute the callback passed to event dispatcher with a get:
     ReferenceError: XMLHttpRequest is not defined
      at dispatchEvent (lib/plugins/event_dispatcher/index.browser.js:51:5)
      at Context.<anonymous> (lib/plugins/event_dispatcher/index.browser.tests.js:86:9)
      at process.topLevelDomainCallback (domain.js:126:23)

@optimizely/optimizely-sdk version:

tested at 764135b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions