openmct/e2e
Shefali Joshi 90662ce4a7
Merge release/2.0.8 into master (#5709)
* Imagery thumbnail regression fixes - 5327 (#5591)

* Add an active class to thumbnail to indicate current focused image

* Differentiate bg color between real-time and fixed

* scrollIntoView inline: center

* Added watcher for bounds change to trigger thumbnail scroll

* Resolve merge conflict with requestHistory change to telemetry collection

* Split thumbnail into sub component

* Monitor isFixed value to unpause playback status

Co-authored-by: Khalid Adil <khalidadil29@gmail.com>

* [e2e] Improve appActions (#5592)

* update selectors to use aria labels

* Update appActions

- Create new function `getHashUrlToDomainObject` to get the browse url to a given object given its uuid

- Create new function `getFocusedObjectUuid`... self explanatory :)

- Update `createDomainObjectWIthDefaults` to make use of the new url generation

- Update `createDomainObject...`'s arguments to be more organized, and accept a parent object

- Update some docs, still need to clarify some

* Update appActions e2e tests

- Refactor for organization

- Test our new appActions in one go

* Update existing usages of `createDomainObject...` to match the new API

* fix accidental renamed export

* Fix jsdoc return types

* refactor telemetryTable test to use appActions

* Improve selectors

* Refactor test

* improve selector

* add clock mode appActions

* lint

* Fix jsdoc

* Code review comments

* mark failing visual tests as fixme temporarily

* Update package.json (#5601)

* Fix menu style in Snow theme (#5557)

* Include the plan source map when generating the time list/plan hybrid object (#5604)

* Search should indicate in progress and no results states, filter orphaned results (#5599)

* no matching result implemented

* now filtering annotations that are orphaned

* filter object results without valid paths

* add progress bar

* added e2e tests

* removed extraneous click

* fix typos

* fix unit tests

* lint

* address pr comments

* fix tests

* fix tests, centralize logic to object api, check for root instead

* remove debug statement

* lint

* fix documentation

* lint

* fix doc

* made some optimizations after talking with akhenry

* fix test

* update docs

* fix docs

* Have in-memory search indexer use composition API (#5578)

* need to remove tags and objects on composition removal
* had to separate out emits from load as it was causing memory indexer to loop upon itself

* Add parsing for areIdsEqual util to consistently remove folders (#5589)

* Add parsing util to identifier for ID comparison

* Moved firstIdentifier to top of function

* Lint fix

Co-authored-by: Andrew Henry <akhenry@gmail.com>

* Revert "Have in-memory search indexer use composition API (#5578)" (#5609)

This reverts commit 7cf11e177c.

* [e2e] Tests for Display Layout and LAD Tables and telemetry (#5607)

* Check for circular references in originalPath - 5615 (#5619)

* check for circular references

* add test

* fix test

* address PR comments by making comments better

* fix docs...again

* Update version number

* Prevent cyclic references in link & move actions (#5635)

* do not create circular refs

* add negative validation test

* move to plugin

* add link test too

* fix docs

* refactored per john request

* fix path

* use appAction lib

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>

* [Condition Set] Add check for empty string being passed to the makeKeyString util by TelemetryCriterion (#5636) (#5663)

* Check telemetry is defined before using makeKeyString util

* Add optional chaining in the check

* Add e2e test

* Add check for undefined

Co-authored-by: Khalid Adil <khalidadil29@gmail.com>

* [Fault Management] New Example Provider, Unit and e2e tests (#5579)

* added unit tests for fault management plugin

* modified the example fault provider to work out of the box

* updating for new e2e folder structure

* part of the e2e tests

* WIP

* Imagery thumbnail regression fixes - 5327 (#5569)

* Add an active class to thumbnail to indicate current focused image

* Differentiate bg color between real-time and fixed

* scrollIntoView inline: center

* Added watcher for bounds change to trigger thumbnail scroll

* Resolve merge conflict with requestHistory change to telemetry collection

* Split thumbnail into sub component

* Monitor isFixed value to unpause playback status

* updated search to include name, namespace and description added some more e2e tests

* added rest of e2e tests

* fixed my init script, had to disable lint for no-force because it was not working without it, saw online this may be a pw bug

* fix: removing maelstrom theme from application (#5600)

* added some tests for no faults

* visual tests

* added visual tests for fault management

* created utils file for shared functionality between function and visual tests

* updating to 2.0.8

* tryin to remove imagery changes from master

* trying to trigger a refresh

* tryin to refresh

* updated search to include name, namespace and description added some more e2e tests

* added rest of e2e tests

* fix: removing maelstrom theme from application (#5600)

* fixed my init script, had to disable lint for no-force because it was not working without it, saw online this may be a pw bug

* added some tests for no faults

* visual tests

* added visual tests for fault management

* created utils file for shared functionality between function and visual tests

* updating to 2.0.8

* no clue

* still no clue

* removing imports and chaning to requires

* updating utils file to work with require

* fixing paths

* fixing a test I had messed up when adding static exmaple faults

* ONE LAST PATH FIX... hopefully

* typo in files fix

* fix folder typo

* thought I got this one, but apparently not, well I did now! who is laughing now!?

Co-authored-by: Michael Rogers <contact@mhrogers.com>
Co-authored-by: Vitor Henckel <vitor@henckel.com.br>

* Sort tree items locally on rename (#5643)

* fix typo

* Sort the tree items locally on object rename

* Use the navigationPath as a key

- This ensures that objects AND linked objects will be sorted

* add 'tree' and 'treeitem' roles to mct-tree

* WIP tree item reordering test

* Select the first object that matches

* Test that all object links are also reordered

* Get the final uuid before queryParams as notebook sections have uuids

* Make `openObjectTreeContextMenu` more deterministic and update usage

* Add `expandPathToTreeItem` and `expandTreeItemByName` appActions

* add `#tree-pane` id for the tree view

* Add tree visual component test suite and bump percy-cli

* Remove tree appActions

* Better variable name

Co-authored-by: Scott Bell <scott@traclabs.com>

* Mct5549 fix indexer composition error (#5610)

* [Display Layout] Composition and configuration sync (#5669)

LGTM

* [e2e] Stabilize notebook tag tests (#5681)

* Use more deterministic selector

* Hover first to "slow down" e2e actions while in headless mode

* Moves condition set fix into 2.0.8 (#5673)

* Set Focused Image index after a imagery is selected from a timestrip - 5632 (#5664)

* Set focused image when timestamp prop is passed in

* Unused var

* Create timestrip with imagery child

* Add equality check for hovered image and view large image url

* Cleanup

* Time List 5534 for release/2.0.8 (#5678)

* Changes to Time List view. Closes #5534.
- Compacted table row spacing.
- Set all timeframes to display by default when creating a new Time List.
- Removed 'Upload plan' file button from properties.

* Changes to Time List view. Closes #5534.
- Better hint text for editing Timeframe Inspector section.

Co-authored-by: Andrew Henry <akhenry@gmail.com>

* [CI] Enable couchdb e2e testing in open source (#5655)

* Handle couch db not found errors so that interceptors are still invoked. (#5654)

* Fix tests for interceptors
* [e2e] Add test for 'mine' folder initialization
* [e2e] don't fail on expected console errors

Co-authored-by: Andrew Henry <akhenry@gmail.com>
Co-authored-by: Scott Bell <scott@traclabs.com>
Co-authored-by: John Hill <john.c.hill@nasa.gov>
Co-authored-by: Jesse Mazzella <jesse.d.mazzella@nasa.gov>

* [Docs] Update CouchDB local install documentation (#5692)

* Update local CouchDB install docs to include docker workflow

* reformat to source configuration scripts where possible

* correct couchdb case

Co-authored-by: John Hill <john.c.hill@nasa.gov>

* [Time Conductor] History not working correctly (#5687)

* the check for fixed time vs realtime was not updating, have fixed this

* merging in related changes from master pr #4414

* lint fixes

* Update src/plugins/timeConductor/ConductorHistory.vue

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>

* setting time mode directly on load

* fixing issue where realtime history was being wiped on reloads while viewing fixed time

* formatting

* stubbed in some tests

Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>

* Only index if provider does not support search - mct5690 (#5693)

* only index if provider does not support search

* add some tests

* fix tests

* [e2e] Add search couchdb test for duplicates

* [e2e] Modify existing search test instead

* lint

Co-authored-by: Jesse Mazzella <jesse.d.mazzella@nasa.gov>

* Don't re-request historical data on ticks (#5701)

Don't rerequest telemetry on ticks.

* Fix duplicate declaration from merge

Co-authored-by: Michael Rogers <contact@mhrogers.com>
Co-authored-by: Khalid Adil <khalidadil29@gmail.com>
Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com>
Co-authored-by: John Hill <john.c.hill@nasa.gov>
Co-authored-by: Charles Hacskaylo <charlesh88@gmail.com>
Co-authored-by: Andrew Henry <akhenry@gmail.com>
Co-authored-by: Scott Bell <scott@traclabs.com>
Co-authored-by: Alize Nguyen <alizenguyen@gmail.com>
Co-authored-by: Jamie V <jamie.j.vigliotta@nasa.gov>
Co-authored-by: Vitor Henckel <vitor@henckel.com.br>
Co-authored-by: Jesse Mazzella <jesse.d.mazzella@nasa.gov>
2022-08-24 11:08:17 -07:00
..
helper Merge release/2.0.8 into master (#5709) 2022-08-24 11:08:17 -07:00
test-data [e2e] Refactor and document our extension of existing Playwright API and RFE features (#5537) 2022-07-27 14:31:18 -07:00
tests Merge release/2.0.8 into master (#5709) 2022-08-24 11:08:17 -07:00
.eslintrc.js [e2e] Add eslint rule for max nested describes (#5565) 2022-07-28 15:50:31 +00:00
.percy.yml [e2e] Update Playwright config to include MMOC and Ipad (#4717) 2022-01-14 14:47:35 -08:00
appActions.js Merge release/2.0.8 into master (#5709) 2022-08-24 11:08:17 -07:00
baseFixtures.js [e2e] Refactor and document our extension of existing Playwright API and RFE features (#5537) 2022-07-27 14:31:18 -07:00
playwright-ci.config.js Add Visual Test for Snow Theme and add visual tests to PR execution (#5570) 2022-07-29 17:35:43 -07:00
playwright-local.config.js [e2e] Refactor and document our extension of existing Playwright API and RFE features (#5537) 2022-07-27 14:31:18 -07:00
playwright-performance.config.js 2.0.5 Backmerge (#5505) 2022-07-14 14:52:28 -07:00
playwright-visual.config.js Add Visual Test for Snow Theme and add visual tests to PR execution (#5570) 2022-07-29 17:35:43 -07:00
pluginFixtures.js Add Visual Test for Snow Theme and add visual tests to PR execution (#5570) 2022-07-29 17:35:43 -07:00
README.md [e2e] More VIPER compatibility fixes (#5582) 2022-07-29 16:50:40 -07:00

e2e testing

This document captures information specific to the e2e testing of Open MCT. For general information about testing, please see the Open MCT README.

Table of Contents

This document is designed to capture on the What, Why, and How's of writing and running e2e tests in Open MCT. Please use the built-in Github Table of Contents functionality at the top left of this page or the markup.

  1. Getting Started
  2. Types of Testing
  3. Architecture

Getting Started

While our team does our best to lower the barrier to entry to working with our e2e framework and Open MCT, there is a bit of work required to get from 0 to 1 test contributed.

Getting started with Playwright

If this is your first time ever using the Playwright framework, we recommend going through the Getting Started Guide which can be completed in about 15 minutes. This will give you a concise tour of Playwright's functionality and an understanding of the official Playwright documentation which we leverage in Open MCT.

Getting started with Open MCT's implementation of Playwright

Once you've got an understanding of Playwright, you'll need a baseline understanding of Open MCT:

  1. Follow the steps Building and Running Open MCT Locally
  2. Once you're serving Open MCT locally, create an Example Telemetry Object (e.g.: 'Sine Wave Generator')
  3. Create a 'Plot' Object (e.g.: 'Stacked Plot')
  4. Expand the Tree on the left-hand nav and drag and drop the Example Telemetry Object into the Plot Object
  5. Create a 'Display Layout' object
  6. From the Tree, Drag the Plot object into the Display Layout

What you've created is a display which mimics the display that a mission control operator might use to understand and model telemetry data.

Recreate the steps above with Playwright's codegen tool:

  1. npm run start in a terminal window
  2. Open another terminal window and start the Playwright codegen application npx playwright codegen
  3. Navigate the browser to http://localhost:8080
  4. Click the Create button and notice how your actions in the browser are being recorded in the Playwright Inspector
  5. Continue through the steps 2-6 above

What you've created is an automated test which mimics the creation of a mission control display.

Next, you should walk through our implementation of Playwright in Open MCT:

  1. Close any terminals which are serving up a local instance of Open MCT
  2. Run our 'Getting Started' test in debug mode with npm run test:e2e:local -- exampleTemplate --debug
  3. Step through each test step in the Playwright Inspector to see how we leverage Playwright's capabilities to test Open MCT

Types of e2e Testing

e2e testing describes the layer at which a test is performed without prescribing the assertions which are made. Generally, when writing an e2e test, we have three choices to make on an assertion strategy:

  1. Functional - Verifies the functional correctness of the application. Sometimes interchanged with e2e or regression testing.
  2. Visual - Verifies the "look and feel" of the application and can only detect undesirable changes when compared to a previous baseline.
  3. Snapshot - Similar to Visual in that it captures the "look" of the application and can only detect undesirable changes when compared to a previous baseline. Generally not preferred due to advanced setup necessary.

When choosing between the different testing strategies, think only about the assertion that is made at the end of the series of test steps. "I want to verify that the Timer plugin functions correctly" vs "I want to verify that the Timer plugin does not look different than originally designed".

We do not want to interleave visual and functional testing inside the same suite because visual test verification of correctness must happen with a 3rd party service. This service is not available when executing these tests in other contexts (i.e. VIPER).

Functional Testing

The bulk of our e2e coverage lies in "functional" test coverage which verifies that Open MCT is functionally correct as well as defining how we expect it to behave. This enables us to test the application exactly as a user would, while prescribing exactly how a user can interact with the application via a web browser.

Visual Testing

Visual Testing is an essential part of our e2e strategy as it ensures that the application appears correctly to a user while it compliments the functional e2e suite. It would be impractical to make thousands of assertions functional assertions on the look and feel of the application. Visual testing is interested in getting the DOM into a specified state and then comparing that it has not changed against a baseline.

For a better understanding of the visual issues which affect Open MCT, please see our bug tracker with the label:visual filter applied here To read about how to write a good visual test, please see How to write a great Visual Test.

npm run test:e2e:visual will run all of the visual tests against a local instance of Open MCT. If no PERCY_TOKEN API key is found in the terminal or command line environment variables, no visual comparisons will be made.

Percy.io

To make this possible, we're leveraging a 3rd party service, Percy. This service maintains a copy of all changes, users, scm-metadata, and baselines to verify that the application looks and feels the same unless approved by a Open MCT developer. To request a Percy API token, please reach out to the Open MCT Dev team on GitHub. For more information, please see the official Percy documentation

(Advanced) Snapshot Testing

Snapshot testing is very similar to visual testing but allows us to be more precise in detecting change without relying on a 3rd party service. Unfortuantely, this precision requires advanced test setup and teardown and so we're using this pattern as a last resort.

To give an example, if a single visual test assertion for an Overlay plot is run through multiple DOM rendering engines at various viewports to see how the Plot looks. If that same test were run as a snapshot test, it could only be executed against a single browser, on a single platform (ubuntu docker container).

Read more about Playwright Snapshots

Open MCT's implementation -Our Snapshot tests receive a @snapshot tag. -Snapshots need to be executed within the official playwright container to ensure we're using the exact rendering platform in CI and locally

docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:[GET THIS VERSION FROM OUR CIRCLECI CONFIG FILE]-focal /bin/bash
npm install
npx playwright test --config=e2e/playwright-ci.config.js --project=chrome --grep @snapshot

(WIP) Updating Snapshots When the @snapshot tests fail, they will need to be evaluated to see if the failure is an acceptable change or

Performance Testing

The open source performance tests function mostly as a contract for the locator logic, functionality, and assumptions will work in our downstream, closed source test suites.

They're found in the /e2e/tests/performance repo and are to be executed with the following npm script:

npm run test:perf

These tests are expected to become blocking and gating with assertions as we extend the capabilities of playwright.

Test Architecture and CI

Architecture (TODO)

File Structure

Our file structure follows the type of type of testing being excercised at the e2e layer and files containing test suites which matcher application behavior or our src and example layout. This area is not well refined as we figure out what works best for closed source and downstream projects. This may change altogether if we move e2e to it's own npm package.

  • ./helper - contains helper functions or scripts which are leveraged directly within the testsuites. i.e. non-default plugin scripts injected into DOM
  • ./test-data - contains test data which is leveraged or generated in the functional, performance, or visual test suites. i.e. localStorage data
  • ./tests/functional - the bulk of the tests are contained within this folder to verify the functionality of open mct
  • ./tests/functional/example/ - tests which specifically verify the example plugins
  • ./tests/functional/plugins/ - tests which loosely test each plugin. This folder is the most likely to change. Note: some @snapshot tests are still contained within this structure
  • ./tests/framework/ - tests which verify that our testframework functionality and assumptions will continue to work based on further refactoring or playwright version changes
  • ./tests/performance/ - performance tests
  • ./tests/visual/ - Visual tests
  • ./appActions.js - Contains common fixtures which can be leveraged by testcase authors to quickly move through the application when writing new tests.
  • ./baseFixture.js - Contains base fixtures which only extend default @playwright/test functionality. The goal is to remove these fixtures as native Playwright APIs improve.

Our functional tests end in *.e2e.spec.js, visual tests in *.visual.spec.js and performance tests in *.perf.spec.js.

Configuration

Where possible, we try to run Open MCT without modification or configuration change so that the Open MCT doesn't fail exclusively in "test mode" or in "production mode".

Open MCT is leveraging the config file pattern to describe the capabilities of Open MCT e2e where it's run

  • ./playwright-ci.config.js - Used when running in CI or to debug CI issues locally
  • ./playwright-local.config.js - Used when running locally
  • ./playwright-performance.config.js - Used when running performance tests in CI or locally
  • ./playwright-visual.config.js - Used to run the visual tests in CI or locally

Test Tags

Test tags are a great way of organizing tests outside of a file structure. To learn more see the official documentation here Current list of test tags:

  • @ipad - Test case or test suite is compatible with Playwright's iPad support and Open MCT's read-only mobile view (i.e. no Create button).
  • @gds - Denotes a GDS Test Case used in the VIPER Mission.
  • @addInit - Initializes the browser with an injected and artificial state. Useful for loading non-default plugins. Likely will not work outside of app.js.
  • @localStorage - Captures or generates session storage to manipulate browser state. Useful for excluding in tests which require a persistent backend (i.e. CouchDB).
  • @snapshot - Uses Playwright's snapshot functionality to record a copy of the DOM for direct comparison. Must be run inside of the playwright container.
  • @unstable - A new test or test which is known to be flaky.
  • @2p - Indicates that multiple users are involved, or multiple tabs/pages are used. Useful for testing multi-user interactivity.

Continuous Integration

The cheapest time to catch a bug is Pre-merge. Unfortuantely, this is the most expensive time to run all of the tests since each Merge event can consistent of hundreds of commits. For this reason, we're selective in what we run as much as when we run it.

We leverage CircleCI to run tests against each commit and inject the Test Reports which are generated by playwright so that they team can keep track of flaky and historical Test Trends

We leverage Github Actions / Workflows to execute tests as it gives us the ability to run against multiple operating systems with greater control over git event triggers (i.e. Run on a PR Comment event).

Our CI environment consists of 3 main modes of operation:

1. Per-Commit Testing

CircleCI

  • Stable e2e tests against ubuntu and chrome
  • Performance tests against ubuntu and chrome
  • e2e tests are linted

2. Per-Merge Testing

Github Actions / Workflow

  • Full suite against all browsers/projects. Triggered with Github Label Event 'pr:e2e'
  • Visual Tests. Triggered with Github Label Event 'pr:visual'

3. Scheduled / Batch Testing

Nightly Testing in Circle CI

  • Full e2e suite against ubuntu and chrome
  • Performance tests against ubuntu and chrome

Github Actions / Workflow

  • Visual Test baseline generation.

Parallelism and Fast Feedback

In order to provide fast feedback in the Per-Commit context, we try to keep total test feedback at 5 minutes or less. That is to say, A developer should have a pass/fail result in under 5 minutes.

Playwright has native support for semi-intelligent sharding. Read about it here.

We will be adjusting the parallelization of the Per-Commit tests to keep below the 5 minute total runtime threshold.

In addition to the Parallelization of Test Runners (Sharding), we're also running two concurrent threads on every Shard. This is the functional limit of what CircelCI Agents can support from a memory and CPU resource constraint.

So for every commit, Playwright is effectively running 4 x 2 concurrent browsercontexts to keep the overall runtime to a miminum.

At the same time, we don't want to waste CI resources on parallel runs, so we've configured each shard to fail after 5 test failures. Test failure logs are recorded and stored to allow fast triage.

Test Promotion

In order to maintain fast and reliable feedback, tests go through a promotion process. All new test cases or test suites must be labeled with the @unstable annotation. The Open MCT dev team runs these unstable tests in our private repos to ensure they work downstream and are reliable.

To run the stable tests, use the npm run test:e2e:stable command. To run the new and flaky tests, use the npm run test:e2e:unstable command.

A testcase and testsuite are to be unmarked as @unstable when:

  1. They run as part of "full" run 5 times without failure.
  2. They've been by a Open MCT Developer 5 times in the closed source repo without failure.

Cross-browser and Cross-operating system

  • Where is it tested
  • What's supported
  • Mobile

Test Design, Best Practices, and Tips & Tricks

Test Design (TODO)

  • How to make tests robust to function in other contexts (VISTA, VIPER, etc.)
    • Leverage the use of appActions.js like getOrCreateDomainObject
  • How to make tests faster and more resilient
    • When possible, navigate directly by URL
    • Leverage await page.goto('/', { waitUntil: 'networkidle' });
    • Avoid repeated setup to test to test a single assertion. Write longer tests with multiple soft assertions.

How to write a great test (TODO)

How to write a great visual test (TODO)

Best Practices

For now, our best practices exist as self-tested, living documentation in our exampleTemplate.e2e.spec.js file.

Tips & Tricks (TODO)

The following contains a list of tips and tricks which don't exactly fit into a FAQ or Best Practices doc.

  • Working with multiple pages There are instances where multiple browser pages will need to be opened to verify multi-page or multi-tab application behavior.

Reporting

Test Reporting is done through official Playwright reporters and the CI Systems which execute them.

We leverage the following official Playwright reporters:

  • HTML
  • junit
  • github annotations
  • Tracefile
  • Screenshots

When running the tests locally with the npm run test:local command, the html report will open automatically on failure. Inside this HTML report will be a complete summary of the finished tests. If the tests failed, you'll see embedded links to screenshot failure, execution logs, and the Tracefile.

When looking at the reports run in CI, you'll leverage this same HTML Report which is hosted either in CircleCI or Github Actions as a build artifact.

e2e Code Coverage

Code coverage is collected during test execution using our custom baseFixture. The raw coverage files are stored in a .nyc_report directory to be converted into a lcov file with the following nyc command:

npm run cov:e2e:report

At this point, the nyc linecov report can be published to codecov.io with the following command:

npm run cov:e2e:stable:publish for the stable suite running in ubuntu. or npm run cov:e2e:full:publish for the full suite running against all available platforms.

Codecov.io will combine each of the above commands with Codecov.io Flags. Effectively, this allows us to combine multiple reports which are run at various stages of our CI Pipeline or run as part of a parallel process.

This e2e coverage is combined with our unit test report to give a comprehensive (if flawed) view of line coverage.

Other

About e2e testing

e2e testing is an industry-standard approach to automating the testing of web-based UIs such as Open MCT. Broadly speaking, e2e tests differentiate themselves from unit tests by preferring replication of real user interactions over execution of raw JavaScript functions.

Historically, the abstraction necessary to replicate real user behavior meant that:

  • e2e tests were "expensive" due to how much code each test executed. The closer a test replicates the user, the more code is needed run during test execution. Unit tests could run smaller units of code more efficiently.
  • e2e tests were flaky due to network conditions or the underlying protocols associated with testing a browser.
  • e2e frameworks relied on a browser communication standard which lacked the observability and controls necessary needed to reach the code paths possible with unit and integration tests.
  • e2e frameworks provided insufficient debug information on test failure

However, as the web ecosystem has matured to the point where mission-critical UIs can be written for the web (Open MCT), the e2e testing tools have matured as well. There are now fewer "trade-offs" when choosing to write an e2e test over any other type of test.

Modern e2e frameworks:

  • Bypass the surface layer of the web-application-under-test and use a raw debugging protocol to observe and control application and browser state.
  • These new browser-internal protocols enable near-instant, bi-directional communication between test code and the browser, speeding up test execution and making the tests as reliable as the application itself.
  • Provide test debug tooling which enables developers to pinpoint failure

Furthermore, the abstraction necessary to run e2e tests as a user enables them to be extended to run within a variety of contexts. This matches the extensible design of Open MCT.

A single e2e test in Open MCT is extended to run:

  • Against a matrix of browser versions.
  • Against a matrix of OS platforms.
  • Against a local development version of Open MCT.
  • A version of Open MCT loaded as a dependency (VIPER, VISTA, etc)
  • Against a variety of data sources or telemetry endpoints.

Why Playwright?

Playwright was chosen as our e2e framework because it solves a few VIPER Mission needs:

  1. First-class support for Automated Performance Testing
  2. Official Chrome, Chrome Canary, and iPad Capabilities
  3. Support for Browserless.io to run tests in a "hermetically sealed" environment
  4. Ability to generate code coverage reports

FAQ

  • How does this help NASA missions?
  • When should I write an e2e test instead of a unit test?
  • When should I write a functional vs visual test?
  • How is Open MCT extending default Playwright functionality?
  • What about Component Testing?

Troubleshooting

  • Why is my test failing on CI and not locally?
  • How can I view the failing tests on CI?
  • Tests won't start because 'Error: http://localhost:8080/# is already used...' This error will appear when running the tests locally. Sometimes, the webserver is left in an orphaned state and needs to be cleaned up. To clear up the orphaned webserver, execute the following from your Terminal: lsof -n -i4TCP:8080 | awk '{print$2}' | tail -1 | xargs kill -9