ccampbell / luna-testing

Simple, modern, opinionated JavaScript unit testing
https://craig.is/testing/code
MIT License
151 stars 6 forks source link

Some questions #10

Open odeds opened 5 years ago

odeds commented 5 years ago

Hi,

really liked the project, it should be getting much more attraction in my opinion. i have also went down the same road of AVA, tape, mocha and got to this project from searching for a unit test library with import/export support out of the box.

i have some questions if you don't mind:

1) is the project active and are you using it in production? 2) do you think puppeteer can be optional for those who just want to use node? 3) in my project, i am using aliases with rollup, so i need to import with relative path my source files, which could have their own aliases imports. do you thing it's possible to add external plugins to the rollup pipeline?

will be happy to contribute the code my self if you think that's a good direction.

ccampbell commented 5 years ago

Hi there,

Thanks for reaching out.

  1. The project is active, but I wouldn’t say I am actively working on it right now. I am using it on a few other projects that are still in development. I actually wrote it because I wanted a simple way to have actual browser testing with APIs such as the Web Crypto API without requiring polyfills and having the tests actually run in Node.

    I have been approaching development on Luna that way too. As I add tests and work on my other projects, if I find something missing/lacking in Luna, I will fix it.

  2. Do you mean have it possible to install Luna without puppeteer as a dependency? Unfortunately, that wouldn’t be possible without having a completely separate repository since npm and package.json do not allow conditional dependencies. If you use the --node flag when you run your tests it will never actually use or launch puppeteer though.

  3. Can you give an example of how it needs to work and what is not working? I use relative paths with my imports too, but I think you have to always reference them relative to the actual sources vs. by name.

    There are definitely advantages to being able to add additional rollup plugins. I just haven’t been able to think of a clean way to do it. I really don’t want to add support for Luna config files, but there may be simple rollup things that can happen conditionally. What I mean is, perhaps it is possible that it can detect at runtime that the bundles need to use a certain rollup plugin and then it can use that.

I am definitely open to contributions, I just want to keep the scope of Luna very simple/limited.

odeds commented 5 years ago

Thanks for the quick response.

1) 👍

2) It's unfortunate that npm doesn't allow conditional dependencies. i don't want to install puppeteer if i am not using it.

3) I am using alias for my imports, for example instead of writing packages/utils/src/fp or ../../ from some another package i use the alias utils, so it can be for example: import {map} from 'utils/fp'. i am doing it with this rollup plugin: https://github.com/rollup/rollup-plugin-alias.

I am not sure how it can be done unless you can use or read the plugins list from the rollup config file, but doesn't seem like a good idea anyway. i think that adding an optional config file can be helpful, it will be like parcel, which have most of the things out of the box, but if you need fine tuning, you can do it via config file.

Wish you best of luck with the project, probably going to check it again in the future! :)