Php tests and error boundaries in react router#2140
Draft
jaltekruse wants to merge 37 commits intoDoenet:legacyfrom
Draft
Php tests and error boundaries in react router#2140jaltekruse wants to merge 37 commits intoDoenet:legacyfrom
jaltekruse wants to merge 37 commits intoDoenet:legacyfrom
Conversation
Contributor
jaltekruse
commented
May 17, 2023
- this is based on top of the branch that adds Jest, so comments on those first couple of commits can be directed to the dedicated PR for that - Add jest for javascript testing #2138
- I want to add tests for the error boundaries, but we won't necessarily always be able to manipulate the back-end to throw an error for any request using the tools accessible from cypress. We still want to test we have defensive code in javascript if unexpected things happen, like the database being temporarily down, future code changes cause bugs, etc.
- So I wanted to have both the error boundaries code together with adding javascript unit tests, as I think we will likely need to have some off the test coverage for handling errors to be just in javascript and simulating error responses from the server, I'll be adding those tests soon
- I still need to do a little cleanup on this branch before it is ready for merging, but I wanted to get up the example of a php based test for an API
… together - current error - TypeError: Cannot read properties of undefined (reading 'subscribe')
- I forgot to stage the right file last commit, so I didn't save my in-progress state, but I did end up copying it to start with the simpler version and fix it
…plete cypress test
- was a minor fix to get the code to run from a unit test, will worry about this later when I finish that test and fix the bug
…cally, must use axios requests! don't use fetch()
… failed network request
…hares a route with the parent
…be treated differently
…reading results from SQL is safe, TODO still need to cast to tinyint to make it clear what is a boolean
…ecking for SQL errors, remove some boilerplate
- had to implement a little workaround for capturing script output, as PHPUnit has some functionality around this, but it is a bit restrictive. You cannot include/call more than one script while also wanting to assert on the output of any of the scripts, as it doesn't include an API to clear the output buffer, just to access the current contents, which can still be appended to by later code run during the test. This also include test setup code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.