question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve Cypress testing against non-functioning app.js

See original GitHub issue

Where to find the issue

Cypress test suite for cwa-website https://github.com/corona-warn-app/cwa-website/tree/master/cypress

Describe the issue

Running the Cypress test suite against the production webserver https://www.coronawarn.app on May 10, 2022 when there were multiple website issues occurring (see #2870) failed to identify any issue. The test suite passed although at the time the Google Chrome console was showing the error:

www.coronawarn.app/:1 Refused to execute script from 'https://www.coronawarn.app/assets/js/app.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.

This error condition prevented many essential functions on the website from being available.

Steps to reproduce

Local clone

To simulate the mime problem locally, test with a removed app.js JavaScript file. From a bash prompt at the root of the cloned cwa-website repository execute:

  1. npm run test:open
  2. Manually delete /public/assets/js/app.js from generated local directory under cwa-website
  3. Go to page http://localhost:8000/en/analysis/ in web browser and confirm “No data to display” in dashboard graphs (showing that web is broken)
  4. In Cypress test runner click on “Run 6 integration tests”
  5. Note that 87 tests pass and 0 tests fail, even though app.js is not available

Production server

To run the Cypress test suite against the production server, navigate in a bash prompt to the root of the cloned cwa-website repository and execute

npx cypress run -c baseUrl=https://coronawarn.app or npx cypress open -c baseUrl=https://coronawarn.app to run individual tests

Suggested enhancement

Add a new Cypress test to check for correct mime types.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MikeMcC399commented, May 13, 2022
  • PR #2890 has been merged, so this enhancement request has now been fulfilled.
1reaction
MikeMcC399commented, May 13, 2022

@Ein-Tim

Will the PR extend the test suite to check for the absence of app.js (that’s what you described in your steps to reproduce) or will it check for malfunctions of app.js?

You can view the test code in PR #2890 now. Its purpose is to check the mime types, which was the root cause of the problem https://github.com/corona-warn-app/cwa-website/issues/2870. If app.js is missing, the test will also fail with a 404 error, however that was not a problem in production, I just used the file deletion as a way to simulate the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Your App | Cypress Documentation
Step 1: Start your server. Assuming you've successfully installed Cypress and opened Cypress in your project, the first thing you'll want to do...
Read more >
Cypress Best Practices For Test Automation - LambdaTest
This blog will teach you the Cypress best practices to write reliable and high-quality test codes while performing Cypress testing.
Read more >
How to write end-to-end tests with Cypress and Node.js
Write end-to-end tests with Cypress, which offers features include time traveling through your tests and recording tests for later playback.
Read more >
Testing React Apps In 2022 With Cypress: An In-Depth Guide ...
Testing your React apps gives you a safety net. But getting started is cumbersome. Cypress makes it relatively easy. This guide shows you ......
Read more >
How to Test Your Apps using Jest, Testing Library, Cypress ...
Manual vs Automated testing; Functional vs Non-functional testing ... How to test vanilla JS code; How to test a front-end React app with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found