Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70927

Unit tests failing on Github Actions

$
0
0

Hi everyone, first post. I just created a new project using the Ionic CLI. The unit tests ran perfectly. Then I added a .github folder and a workflow which runs the unit tests, and when I checked the code into GitHub, the unit tests failed.

Here’s what the error looks like:

⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
ReferenceError: document is not defined
 ❯ Module.startTapClick node_modules/@ionic/core/components/index9.js:133:15
    131|   };
    132|   const doc = document;
    133|   doc.addEventListener('ionGestureCaptured', cancelActive);
       |               ^
    134|   doc.addEventListener('touchstart', onTouchStart, true);
    135|   doc.addEventListener('touchcancel', onTouchEnd, true);
 ❯ node_modules/@ionic/core/components/ion-app.js:21:113

This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:
- cancel timeouts using clearTimeout and clearInterval
- wait for promises to resolve using the await keyword

I am pretty sure that there’s no error in my GitHub workflow config, as I have used the same workflow for several other projects.

The specific command that is failing is “vitest run”. (The “run” subcommand disables watch mode, which is what you want when running on a CI pipeline). As mentioned, this command works when running locally.

Normally the message “document is not defined” happens when you forget to specify a test environment of jsdom, but that’s not the case here. The jsdom environment was already setup by the Ionic CLI wizard.

The exception gets thrown after the unit tests completed - the tests themselves succeeded with no errors.

I suspect that what’s happening is that some asynchronous process or timer is getting started as a side-effect of running the tests, and then doesn’t get cleaned up afterwards. (I tried manually doing a react-testing-library cleanup - no dice.) Unfortunately, whatever process or timer is not something I’m doing. Is there some Ionic process that I need to await for after the test runs?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>