Skip to content

Specify encoding when asserting a snapshot #21

@daddykotex

Description

@daddykotex

Unfortunately, I'm currently working from a WSL (Windows Subsystem Linux) and the default encoding is not UTF-8. So for example, I'm writing some tests write now to fetch a HTML page and assert it does not change (after a rewrite), unfortunately, the encoding being unspecified, is not UTF-8 and my tests are failing because of weird French accents!

Would you be open to a PR to have a way to specify the encoding when writing the snapshots? I think the problematic method, at least on the JVM , is fileWriteContents.

I had similar issues in other places in my project, and I'd probably fix that by re-writing with something like:

import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths

val writer = Files.newBufferedWriter(Paths.get(s), StandardCharsets.UTF_8)

What do you think?

I guess this could also be configurable through sbt options? Maybe?

Let me know, and thanks for the lib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions