Skip to content
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

☂️ Move Adapters tests to node:test #144

Closed
2 tasks done
alexanderniebuhr opened this issue Jan 30, 2024 · 7 comments
Closed
2 tasks done

☂️ Move Adapters tests to node:test #144

alexanderniebuhr opened this issue Jan 30, 2024 · 7 comments

Comments

@alexanderniebuhr
Copy link
Member

alexanderniebuhr commented Jan 30, 2024

Description

Internally, the team decided to move our testing infrastructure to use node:test instead of Mocha.

While Mocha is good, it has its own quirks. Also, we believe that the Node.js test runner will improve with time.

This is an excellent opportunity to contribute to Astro and help us with the migration because you don't need to understand Astro logic. So if you have been looking for an opportunity to contribute to Astro, this is the perfect chance for you!

Plan

Comment here which integration/adapter you want to migrate first. Failing to comment might nullify your contribution if someone else did the work and commented on the issue. This will help us to avoid having multiple people working on the same thing.

The plan should be as follows:

  1. Migrate tests of our @astrojs/* packages. You can use this PR as a blueprint of what we're looking for, however this repository might be a little different, so this can only be used as a reference: chore(@astrojs/node): use Node.js for testing astro#9758

Integrations/adapters

List of the integrations/adapters

@alexanderniebuhr alexanderniebuhr pinned this issue Jan 30, 2024
@alexanderniebuhr alexanderniebuhr changed the title ☂️ Move Astro tests to node:test ☂️ Move Adapters tests to node:test Jan 30, 2024
@xMohamd
Copy link
Contributor

xMohamd commented Feb 2, 2024

I migrate tests of @astrojs/cloudflare
but when I tried to pnpm run test after edited package.json with next command it , it gives me that error.
test": "astro-scripts test --timeout 3000 \"test/**/*.test.js\"

 pnpm run test

> @astrojs/cloudflare@9.0.0 test C:\Users\Username\Desktop\astro-adapters\packages\cloudflare
> astro-scripts test --timeout 30000 "test/**/*.test.js"

'astro-scripts' is not recognized as an internal or external command,
operable program or batch file.
 ELIFECYCLE  Test failed. See above for more details.

I tried to fix it, but I couldn't,

@alexanderniebuhr
Copy link
Member Author

alexanderniebuhr commented Feb 3, 2024

@xMohamd Thank you. ❤️

We are not using astro-scripts in this repository. So instead of calling that, we should call node directly. I really would appreciate if you already open a PR with the changes you have so far, and I could look the fix for the Error, if you want :)

@abidjappie
Copy link
Contributor

I'd like to try migrating the tests for @astrojs/netlify 🙇

@xMohamd
Copy link
Contributor

xMohamd commented Feb 4, 2024

@xMohamd Thank you. ❤️

We are not using astro-scripts in this repository. So instead of calling that, we should call node directly. I really would appreciate if you already open a PR with the changes you have so far, and I could look the fix for the Error, if you want :)

@alexanderniebuhr #150 Check it and let me know if there is any issue

@alexanderniebuhr
Copy link
Member Author

@xMohamd thank you for it.
On the first glance it looks good. I'm going to fix the pnpm script and give it another deeper review!

@abidjappie
Copy link
Contributor

@alexanderniebuhr I have a preliminary PR up.

  1. Do you have any idea how to deal with matchSnapshot in node. As far as I could find, it's not supported and I couldn't find an exposed version of their common/assertSnapshot. I may just be looking in the wrong place though.

  2. I'm currently trying to debug this error when running the tests, will update the PR as soon as I figure it out:

✖ failing tests:

✖ emits an edge function
  'test did not finish before its parent and was cancelled'

✖ does not apply middleware during prerendering
  'test did not finish before its parent and was cancelled'

✖ edgeMiddleware: true (492.317542ms)
  [Error: ENOENT: no such file or directory, open '/Users/abid.jappie/code/withastro-adapters/packages/netlify/test/functions/fixtures/middleware/dist/_astro/astronaut.jcSXTCiO_1Hy9L1.webp'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/Users/abid.jappie/code/withastro-adapters/packages/netlify/test/functions/fixtures/middleware/dist/_astro/astronaut.jcSXTCiO_1Hy9L1.webp' }

✖ does not enable Image CDN (1280.559625ms)
  [Error: ENOENT: no such file or directory, open '/Users/abid.jappie/code/withastro-adapters/packages/netlify/test/functions/fixtures/middleware/dist/_astro/astronaut.jcSXTCiO_1Hy9L1.webp'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/Users/abid.jappie/code/withastro-adapters/packages/netlify/test/functions/fixtures/middleware/dist/_astro/astronaut.jcSXTCiO_1Hy9L1.webp' }

Any assistance would help 🙇

@alexanderniebuhr alexanderniebuhr unpinned this issue Feb 16, 2024
@alexanderniebuhr
Copy link
Member Author

Thank you everyone for all contributions! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants