AztecProtocol / dev-rel

All of Aztec's workshops, resources, tutorials, ideas, and useful tools
38 stars 18 forks source link

Set up testing for token bridge tutorial typescript setup code #295

Open critesjosh opened 1 month ago

critesjosh commented 1 month ago

There is setup code that is hardcoded for the cross_chain_messaging.test.ts in this page of the docs.

This section is hard coded because the original e2e test uses a util.js file that uses a bunch of packages that are not published to npm. We use the hard coded section to only use the publicly published packages, but this code can get out of date and will not trigger any failing tests.

Update the e2e tests to include this section of code, and then import it into the docs so it is ensured to always be up to date.

critesjosh commented 3 weeks ago

I looked into this a little bit and it is going to be non-trivial to do well. The glue code snippet in the docs pulls tests from 2 different test files and has its own setup code.

The most straightforward way to get this to work is to create a new e2e test file, add the specific setup code that is required (and import this directly into the docs using the #include_code macro) and then copy the the test functions from the other two files into this test file. The problem with this approach is that it copy+pastes test code across multiple files, so there is redundancy. If the test needs to change, it needs to updated in two places. I couldn't figure out a good way to be able to write the test function in one place while keeping it nice for the docs.