-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding system test #11
Conversation
Some high level test would indeed be nice. Would it make sense to create a folder It currently looks like the snapshot output is not processed at all, it still contains scripts etcetera; am I understanding something incorrectly, or might the mocks have to be restored after the first test? |
Having the system tests in their own directory would make a lot of sense and allow us to run them in parallel also. This is the approach first suggested by @sanjo as well. |
I did still mean to compare the output to the whole snapshot string, I just wondered whether that string could be read from a file; so you'd have e.g. Regarding the output not being processed, have a better look at |
I thought I ran it through every test case. Could you be more specific? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the snapshot looks processed now as it should; I assume the problem was that when it was in the same file as the unit test, the unit test mocked all processing functions and did not restore them, so they were not executed during this test either.
By the way, it would be helpful if you would not amend your commits during back-and-forths like these. That would help us to see clearly what changed since last review. The commits could then still be squashed to one commit before merging the PR.
A problem with this test (as also commented inline) is now that the fetch mock always returns the image, also for the stylesheet. It is unfortunate we cannot give jest-fetch-mock a map of url-response pairs; to get the right responses for each URL we would have to assume the order in which they are fetched, which would be too fragile. I am wondering if we could somehow use the real fetch, or find/make a replacement that reads local files, so we can just put the resources (image and stylesheet) as files in the same folder and fetch
will just get them.
Also, I would make the html file an actual html file, not a script that exports a string. Instead of importing it, you may then have to use something like fs.readFile
to get the string.
}) | ||
|
||
test('should test against the freeze dried page', async () => { | ||
fetch.mockResponse(imageBlob) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need something better here, not every request should return the image.
��� | ||
IHDR����������:~�U��� | ||
IDATx�cb����67|�����IEND�B\`�</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks rather wrong; the fetch
for the stylesheet returns the image..
How about having a look into fetch-mock . The other option we have is to write a mock of the fetch api that can get the files from the local file system. Something along the line of this, but modified for the fetch api.
Yeah, sorry about that. Force of habit, feel its much cleaner to have less number of commits. But yeah I get your point. I'll try and push changes in consecutive commits. |
@Treora |
I added a test similar to (and inspired by) this work in the rewrite (commit 6821123). Closing this. |
This is a top level test that I thought was extremely necessary for the system. I would rather have the file moved to its own file, but I would be cool with anything @Treora and @sanjo decides.