Open JohnAlbin opened 1 year ago
The current tests.nextdrupal.org instance is running Drupal 9.4.x and 99% of the test content is just the Umami demo content. That's good news since it means it might be possible to generate a local test instance (after we figure out what the 1% non-Umami content is). And it means we'll be able to update it to Drupal 10.1 easily too.
One complication is the jest snapshots are generated from the JSON:API data and are polluted with the absolute URL of the test environment and with content UUIDs from that specific instance of the Umami demo.
Alternatively, we could mock a Drupal JSON:API instance and have the Jest tests run against that. Though we'd want to generate the mocks using a live Drupal instance (and then commit the mocks to git) so it might make sense to do both here.
@JohnAlbin have been poking at these tests a bit. Short term to run these tests against tests.nextdrupal.org the only suite that requires valid auth credentials seems to be NextDrupal/crud-methods.test.ts
unsurprisingly. Having just that suite run with mocks would probably go a long way in the short term. In the Drupal API client we did something similar using MSW I'd be wiling to take a shot at that here if that would help.
Jest tests for
next-drupal
fail when run locally.Expected behavior
The TESTING.md documentation tells a developer how to run the tests and the local tests run successfully.
Steps to reproduce:
git clone
this repo.yarn install
yarn test
fails all tests with:Additional context
It's obvious from the Jest failure messages that there are some missing environment variables. It's also clear from looking at the Jest snapshot file, that the Jest tests are being run against a specific live environment, https://tests.next-drupal.org, and are using specific authentication credentials. So we can't allow developers to have those environment variables.
Developers should be able to have local test fixtures to run tests locally.