Skip to content

rewritePaths is less restrictive than expected #14

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

Closed
bitjson opened this issue Feb 11, 2020 · 4 comments · Fixed by #16
Closed

rewritePaths is less restrictive than expected #14

bitjson opened this issue Feb 11, 2020 · 4 comments · Fixed by #16
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@bitjson
Copy link

bitjson commented Feb 11, 2020

Thank you for this project! I migrated bitcoin-ts recently, and I just wanted to note an issue I had.

My Typescript project builds the same source to two different output locations, one build/main/ for Node.js usage and one build/module/ for consumers which use build tools like Rollup.

I primarily test against the build/main/ build, so the configuration seemed simple:

  "ava": {
    "typescript": {
      "rewritePaths": {
        "src/": "build/main/"
      }
    }
  }

But with that configuration, AVA was also trying to test files in the build/module/ folder. I ended up needing to add an exclusion:

  "ava": {
    "typescript": {
      "rewritePaths": {
        "src/": "build/main/"
      }
    },
    "files": [
      "!build/module/**"
    ]
  }

This works well now, so I'm happy to leave it as-is. I just wanted to mention that it differed from my initial impression of how rewritePaths would work. I thought setting src/ to build/main/ would map files in those directories one-to-one, but AVA seems to also be searching in build/module/ without the specific exclusion.

(Thanks again for v3 of AVA and the improved Typescript integration! Even debugging is working beautifully now.)

@novemberborn
Copy link
Member

This works well now, so I'm happy to leave it as-is. I just wanted to mention that it differed from my initial impression of how rewritePaths would work. I thought setting src/ to build/main/ would map files in those directories one-to-one, but AVA seems to also be searching in build/module/ without the specific exclusion.

AVA still searches the entire project for *.js, *.cjs, *.mjs and *.ts files. The TypeScript integration is now smart enough to tell AVA to ignore build/main/, but it doesn't know about build/module/.

Would documentation help here? Looks like you figured out AVA's behavior pretty quick?

(Thanks again for v3 of AVA and the improved Typescript integration! Even debugging is working beautifully now.)

😍

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

@bitjson
Copy link
Author

bitjson commented Feb 12, 2020

AVA still searches the entire project for *.js, *.cjs, *.mjs and *.ts files. The TypeScript integration is now smart enough to tell AVA to ignore build/main/, but it doesn't know about build/module/.

Ah, that makes much more sense. I only figured out I needed to ignore the contents of build/module when I added some console.logs to AVA in node_modules. 😅

Would documentation help here? Looks like you figured out AVA's behavior pretty quick?

Ya, I think an explanation of rewritePaths in the readme would be helpful. It took me a while to look in the right places, and even then, I went away thinking it was a bug.

@novemberborn novemberborn added documentation Improvements or additions to documentation help wanted Extra attention is needed labels Feb 13, 2020
@novemberborn
Copy link
Member

Fair enough.

Let's add something like this to the rewritePaths section in the README:

AVA searches your entire project for *.js, *.cjs, *.mjs and *.ts files (or other extensions you've configured). It will ignore such files found in the rewritePaths targets (e.g. build/). If you use more specific paths, for instance build/main/, you may need to change AVA's files configuration to ignore other directories.

What do you think?

@novemberborn novemberborn reopened this Feb 13, 2020
@bitjson
Copy link
Author

bitjson commented Feb 13, 2020

That’s perfect 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants