Skip to content

Bento Unit Test Isolation #36239

@samouri

Description

@samouri

Description

Bento unit tests are not properly isolated from each other. In the below example, the effects from the amp-iframe run during the tests of amp-render, throwing an error when the ownerDocument is null:

FAILED TESTS:
  amp-render-v1.0
    ● "before each" hook for "renders from amp-state"
      Chrome Headless 94.0.4606.61 (Mac OS 10.15.7)
    Error: Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') (/var/folders/zb/8dhhvh5n5c51pntk5ftm1vjh00kpsq/T/9914e7c3fd7c7098234e6fe35982712c-bundle.js:46041)

We should ensure that a test has fully been cleaned up and all of its effect hooks (and cleanups) have completed running before moving on to the next

Reproduction Steps

npx amp unit --headless --files=extensions/amp-iframe/1.0/test/test-amp-iframe.js,extensions/amp-render/1.0/test/test-amp-render.js

This problem is exacerbated by our recent move towards parallelization. Random noise in how tests are sharded between nodes means that the PR that introduces isolation issues is often not the one that ends up getting blocked.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions