Closed anth-volk closed 2 weeks ago
@anth-volk, what do you mean by "start"?
@czhou578 At present, for any tests that require metadata, we use a beforeAll
to fetch the metadata for the entire test file. While this means that we only need to fetch once for one file (e.g., PolicyRightSidebar.test.js), it has two disadvantages:
test
declarations in the file, but not before all describe
blocks - data declared inside the describe
, for use within all test
s inside of it, cannot access the fetched dataUltimately, we're using the same metadata for every test file. It would be great to have an order of execution whereby the metadata is fetched, then given to all test files, meaning that every run of the test suite would result in just one metadata fetch.
@anth-volk, just to confirm, I'm seeing some test files that are fetching the metadata not in a beforeAll
clause, but within the test
clause, as shown in the image. Do you want me to leave that as it is?
Shoot, actually, could you change that? That's not what this issue refers to, but it would be good to fix that, as well.
Out of curiosity, though, have you determined a way to fetch before all test files? Ideally, this would function in some sort of separate setup file, before the tests, the describe blocks, etc.
Ok. I guess I can change that. I believe I have found a way to run that fetch metadata function before all the test suites. I'm using the setupFilesAfterEnv
property in the jest.config.js
to run a new file I created that has the fetching logic included. I'll open a PR for you soon so you can check.
This is used in various places in the tests, so it would be great to have just one fetch at the start, before all tests