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

[WIP] feat(textlint-tester): implement snapshot testing #548

Closed
wants to merge 2 commits into from

Conversation

azu
Copy link
Member

@azu azu commented Aug 7, 2018

POC: implement snapshot testing using snap-shot-core

It includes very hacky way for bahmutov/snap-shot-core#51
process.chdir is bad...

fix #542

@azu azu added the Status: In Progress Work in Progress label Aug 7, 2018

`

exports['123_345 1'] = `
Copy link
Member Author

Choose a reason for hiding this comment

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

We should define what snapshot output format.

  • Input
  • (Optional) Output
  • (Optional) Lint Message for human

const inputPath = typeof state === "object" ? state.inputPath : undefined;
const ext = typeof state === "object" && state.ext !== undefined ? state.ext : ".md";
const singleName = text.split(/\n/g).join("_");
it(text || inputPath || "NO name", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: should support inputPath correctly

@azu azu added the Type: Feature New Feature label Aug 7, 2018
@azu
Copy link
Member Author

azu commented Aug 7, 2018

It will change rule test flow.

Current:

  • input actual text
  • input expected result manually

Snapshot:

  • input text
  • Run snapshot and generate expected result

@azu
Copy link
Member Author

azu commented Dec 24, 2018

Anothor option: user can specify file name per test case.

tester.run(rule, {
  snapshots: {
    "filename.txt": { text: "string" }
  }
});

@azu
Copy link
Member Author

azu commented Feb 10, 2019

Blocker: bahmutov/snap-shot-core#195

@azu
Copy link
Member Author

azu commented Oct 19, 2019

I'll separate this snapshot testing as other testing library.
e.g. @textlint/snapshot-tester

Because, we need to try it and get error before merging snapshot testing.

@azu
Copy link
Member Author

azu commented Jul 11, 2020

Close this.
We need to create snapshot testing library again #542

We will implement this based on secretlint
https://github.com/secretlint/secretlint/blob/master/packages/%40secretlint/tester/src/index.ts

@azu azu closed this Jul 11, 2020
@azu azu deleted the textlint-tester-snapshot branch July 11, 2020 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Work in Progress Type: Feature New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

textlint-tester: support snapshot testing
1 participant