-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
chore(netlify): use Node.js for testing #158
chore(netlify): use Node.js for testing #158
Conversation
|
@abidjappie Thanks for the PR. Maybe you can consult with @Skn0tt to see if we can rewrite the snapshot test to be still valuable without a snapshot :) |
fa78fa0
to
7c6c22f
Compare
…dentify failures and fixes some issues of leaking test state.
Something I noticed is that either
|
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.
looks good on first sight!
Hmm, I wonder wether that also happens on CI 🤔 Mind sharing the full stacktraces, to see where the |
I'll also migrate this script https://github.com/withastro/astro/blob/main/scripts/cmd/test.js over to the adapters repo, because using the Node's cli has some downsides. Once I've migrated it, we can use it for this PR too. |
@abidjappie, @Skn0tt What is the state? Do we need still to figure stuff out, or can we update this PR with latest main and get this merged? I also just merged #150 which adds support for |
@alexanderniebuhr I'll look into the feedback sometime today, and try to get some stack traces. |
I'm running the tests via await fixture.build(); My guess is that the test are running concurrently, which is why it fails in different places each time. I wrapped it in
|
Could be because of concurrency, yes! I see you replaced |
@alexanderniebuhr can you help me to get the test running using > @astrojs/netlify@5.1.1 test /Users/abid.jappie/code/withastro-adapters/packages/netlify
> pnpm run test-fn && pnpm run test-static
> @astrojs/netlify@5.1.1 test-fn /Users/abid.jappie/code/withastro-adapters/packages/netlify
> astro-scripts --test ./test/functions/*.test.js
> @astrojs/netlify@5.1.1 test-static /Users/abid.jappie/code/withastro-adapters/packages/netlify
> astro-scripts --test ./test/static/*.test.js
|
@Skn0tt
Unfortunately, I think this might solve the issue of file access overlapping in a single test, I think that different test files can still have this effect on one another: I can easily break This also works for running node --test **/image-cdn.test.js
▶ Image CDN
▶ when running outside of netlify
✔ does not enable Image CDN (714.118083ms)
▶ when running outside of netlify (714.634083ms)
▶ when running inside of netlify
✔ enables Netlify Image CDN (326.024042ms)
✔ respects image CDN opt-out (434.420417ms)
▶ when running inside of netlify (760.604291ms)
▶ Image CDN (1475.79075ms)
ℹ tests 3
ℹ suites 3
ℹ pass 3
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 2056.534583 |
Hmm, I'm not sure I follow. Could you push those changes? then I can try running it locally to see what's going wrong. |
@abidjappie let me check |
You can try with this branch. State: If you surround each case in |
This is interesting, using |
@alexanderniebuhr true. I also noticed that running with pnpm run test-fn
> @astrojs/netlify@5.1.2 test-fn /Users/abid.jappie/code/withastro-adapters/packages/netlify
> astro-scripts test ./test/functions/*.test.js
▶ Cookies
✔ Can set multiple (13.354375ms)
✔ renders dynamic 404 page (4.59525ms)
▶ Cookies (597.759083ms)
ℹ tests 2
ℹ suites 1
ℹ pass 2
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 1190.360458 I'm not sure if it supports recursive, but this works for me: "test-fn": "for f in test/functions/*.test.js; do echo $f; astro-scripts test $f; done" Should we update the script ? |
@Skn0tt I've pushed some changes now. You can get all tests to pass. for f in test/functions/*.test.js; do echo $f; pnpm astro-scripts test $f; done It may be related to extraneous asynchronous activity since removing the I think it may need further investigation at some point, but I'm just relieved it's behaving somewhat consistently on my machine now. |
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.
Looks wonderful! Good job at getting all the tests to pass under a new test runner :D
Left a tiny nit, but nothing blocking.
@abidjappie Thank you so much for your contribution. Appreciate the help ❤️ I'll take over from here and make sure this get's merged asap. |
Changes
@astro/netlify
tests to Node.js (original issue: ☂️ Move Adapters tests tonode:test
#144)pnpm exec changeset
Challenges
fs
Testing
For now, run the following command in
packages/netlify
Docs
For now there is no documentation, but that might change