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

Only loading includes one level deep? #6

Open
mspoulsen opened this issue Feb 13, 2020 · 6 comments
Open

Only loading includes one level deep? #6

mspoulsen opened this issue Feb 13, 2020 · 6 comments

Comments

@mspoulsen
Copy link

Hi,

Is it only loading .ne files one level deep?
I have a.ne that includes b.ne that in turn includes c.ne.
However, when testing a.ne it is not loading updates made to c.ne...?

Thanks!

@adam1658
Copy link
Owner

Hi @mspoulsen,

I've investigated a little and have found that Jest is unaware of the dependencies on b.ne and c.ne.

It appears there is a way to be a way to tell Jest that a.ne depends on b.ne and c.ne using https://jestjs.io/docs/en/next/configuration#dependencyextractor-string (a little more context: jestjs/jest#6680)

The hard part I see is generating the list of dependencies. I think you'd have to do some custom compilation of nearley scripts in order to extract the includes.

To do this we may need to compile it twice - once to actually compile it, and a second time where we parse it and extract the includes.

An alternative might be to generate a cache key for jest based on the compilation results. Disadvantages of this approach include:

  • generating a cache key is supposed to be quick, so Jest can avoid redoing the transform. This idea means compiling both when asked to, and every time the cache is re-checked.
  • Jest still would not notice when b.ne or c.ne changes on disk - it would only be watching a.ne

What are your thoughts?

@mspoulsen
Copy link
Author

Hi @adam1658
Thanks for the feedback and sorry for my slow reaction.
I have no opinion about the best approach. I am just a normal user. Not a tooling-guy in any way 😄
I just know that it is not optimal to have a compile step as part of my tdd workflow so I hope you can come up with a good solution. Sorry that I can not be of more help.

@mspoulsen
Copy link
Author

I took a look at https://jestjs.io/docs/en/next/configuration#dependencyextractor-string
Could you show me how to configure this for a nearley file?

@adam1658
Copy link
Owner

I would experiment by copying https://github.com/adam1658/jest-transform-nearley/blob/master/index.js into your app (it's basically the whole transform plugin), then pointing Jest at it instead of the packaged one.

Then you can experiment with adding a second export for dependencyExtractor

I'm working on other projects at the moment so don't have a lot of time for this - let me know if you have any success this way.

@mspoulsen
Copy link
Author

Thanks a lot! I will give it a try 👍

@mspoulsen
Copy link
Author

I did not have any success. Tool much tooling for me 😞
Incredible that jest makes watching certain files so difficult!

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

2 participants