atomicojs / atomico

Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom.
https://atomicojs.dev
MIT License
1.16k stars 43 forks source link

Testing #65

Closed cawfeecoder closed 2 years ago

cawfeecoder commented 2 years ago

Do you guys have an example of using Jest/Web Test Runner/Karma/etc (any testing framework really) to run tests against individual components?

UpperCod commented 2 years ago

I personally recommend that using Web Test Runner works fine with the 2 examples in the documentation

  1. Render, be it DOM state or events. https://atomico.gitbook.io/doc/api/testing/atomico-test-dom
  2. Hooks, https://atomico.gitbook.io/doc/api/testing/test-hooks

I will try to create an example in a repo for your exploration, I will consider the following points:

  1. declaration of props.
  2. module export.
  3. rendering
  4. events

I am attentive to more ideas to solve in the example.

cawfeecoder commented 2 years ago

This might be a dumb question on my part, but I’ve never used web-test-runner. I continually get a “failed to fetch dynamically imported module”. Is this a common error that I have to adjust a config for?

On Tue, Nov 23, 2021 at 11:41 PM Matias Trujillo @.***> wrote:

I personally recommend that using Web Test Runner works fine with the 2 examples in the documentation

  1. Render, be it DOM state or events. https://atomico.gitbook.io/doc/api/testing/atomico-test-dom
  2. Hooks, https://atomico.gitbook.io/doc/api/testing/test-hooks

I will try to create an example in a repo for your exploration, I will consider the following points:

  1. declaration of props.
  2. module export.
  3. rendering
  4. events

I am attentive to more ideas to solve in the example.

— You are receiving this because you authored the thread.

Reply to this email directly, view it on GitHub https://github.com/atomicojs/atomico/issues/65#issuecomment-977528011, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRK6QK23RXWEGJCJVDKX5DUNRUHJANCNFSM5IU4VAVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Regards, Nicholas Frush Founder ghostbox C: 443-974-0421

UpperCod commented 2 years ago

If you have used the command npm init @atomico it is not an error from you, I just detected that in the scaffolding of Atomico there is an error in the name of the file web-test-runner.mjs it should be called as web-test-runner.config.mjs for web test runner to load the configuration via Vite.

In case this persists, check if the test script has the --node-resolve flag, example:

"test": "wtr src/**/*.test.{js,jsx,ts,tsx} --node-resolve",
cawfeecoder commented 2 years ago

That did it! Thanks

On Wed, Nov 24, 2021 at 6:04 PM Matias Trujillo @.***> wrote:

If you have used the command npm init @atomico it is not an error from you, I just detected that in the scaffolding of Atomico there is an error in the name of the file web-test-runner.mjs it should be called as web-test-runner.config.mjs for web test runner to load the configuration via Vite.

In case this persists, check if the test script has the --node-resolve flag, example:

"test": "wtr src/*/.test.{js,jsx,ts,tsx} --node-resolve",

— You are receiving this because you authored the thread.

Reply to this email directly, view it on GitHub https://github.com/atomicojs/atomico/issues/65#issuecomment-978414620, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRK6QLLF35KVQ7Y7CJ3METUNVVPLANCNFSM5IU4VAVQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Regards, Nicholas Frush Founder ghostbox C: 443-974-0421