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

Could we add an option that names / detects files as equivalent when they were run from .ts and transpiled .js? #52

Open
emilgoldsmith opened this issue Mar 20, 2018 · 1 comment

Comments

@emilgoldsmith
Copy link

Thanks for all your work! It works really well. Just a small feature request that someone or me later could pick up and add, as right now if I run a test from a ts file and run the same test from the transpiled js it doesn't recognize the snapshots but creates 2 different snapshot files.

Could be implemented as an option, or maybe even just as the default (if two files differed only in the 1 letter (j vs t in the extension), could also be added for tsx and js I guess, though if default it would be a breaking change

@kuceb
Copy link
Collaborator

kuceb commented Aug 15, 2018

@emilgoldsmith I think by default we could choose to strip the file extension from the filename, for example:
example.spec.ts -> __snapshots__/example.spec.js
example.spec.js -> __snapshots__/example.spec.js
example.spec.jsx -> __snapshots__/example.spec.js

maybe this is suggested somewhere else already however.

As a temporary solution for you, you should be able to do this to modify the filename on the mocha context object. The following will remove the extension from the filename that snapshot reads

beforeEach(function(){
  this.currentTest.file = this.currentTest.file.split('.').slice(0, -1).join('.')
})

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