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

Default options "constructor" and fileExtension option #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

d1manson
Copy link

@d1manson d1manson commented Jun 1, 2021

As it says in the title, I've added two new things here.

The new docs in the readme and extra tests hopefully give sufficient explanation, but essentially I wanted an easy way to specify the file extension at the top of the test file and then have lots of .toMatchFile assertions that automatically use that file extension. Note that this isn't a breaking change.

This didn't take that long to do, so I am happy to make some slight tweaks if needed, but obviously I'd be keen to get it merged with minimal effort if possible.

Thanks!

@d1manson
Copy link
Author

d1manson commented Jun 1, 2021

Initially I thought you could scope your extension to a describe/it block, but that doesn't seem to be the case. I've had a quick search of the docs to confirm that extensions are at least scoped to a file but couldn't actually find that mentioned (though I'm fairly sure it is the case).
At any rate, I've used separate test files in order to test out multiple versions of the extension.

Copy link
Owner

@satya164 satya164 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

I'm not sure another matcher toMatchFileUsing is necessary. Can't we just do the following:

expect.extend({
  toMatchFile: (content, filepath, options) =>
    toMatchFile(content, filepath, { fileExtension: '.md', ...options }),
});

I just merged #29 which adds a fileExtension option.

@satya164 satya164 force-pushed the main branch 3 times, most recently from cf6a5e9 to 9688704 Compare July 8, 2024 14:13
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

Successfully merging this pull request may close these issues.

None yet

2 participants