Snap.swift icon indicating copy to clipboard operation
Snap.swift copied to clipboard

Remove `test` method prefix from reference files

Open Jeehut opened this issue 7 years ago • 3 comments

Currently, when I follow the XCTest naming guidelines and write test names like this:

    func testBasicRendering() {
        expect(snapshotView).toMatchSnapshot()
    }

I get files named like this:

[email protected]

I would have expected the name to be reference_basicrendering, so the test prefix should be removed as it is part of any test method. It's redundant information.

Jeehut avatar Feb 19 '18 16:02 Jeehut

Hey mate, thanks for the feedback, I think we can make that option configurable so it's opt-in and the current tests for users don't break, also, I don't know if you know that you can pass a custom name to any snapshot like this

expect(snapshotView).toMatchSnapshot(named: "basic_rendering")

skyweb07 avatar Feb 20 '18 09:02 skyweb07

I know that, but I think the defaults should definitely be more swifty or at least provide the option to be so. Another possibility is that we keep support for the test prefix when matching, but only create new references without the test prefix. That way existing tests would still work but the redundant stuff would be gone long term.

Jeehut avatar Feb 21 '18 13:02 Jeehut

Yeah, I think we can do something like that using the Snap Config so it's opt-in by the user, I'll try to do that this afternoon

skyweb07 avatar Feb 21 '18 14:02 skyweb07