giacomocavalieri / birdie

🐦‍⬛ Snapshot testing in Gleam
https://hexdocs.pm/birdie/
Apache License 2.0
92 stars 6 forks source link

Incorrect "... is not a valid snapshot" message on the JS target #4

Closed MystPi closed 8 months ago

MystPi commented 8 months ago

This bug does not appear to affect the erlang target.

Snapshots are incorrectly identified as invalid when testing using birdie 1.1.0. Error message:

❌ It looks like "./birdie_snapshots/a_test.accepted"
is not a valid snapshot.
This might happen when someone modifies its content.
Try deleting the snapshot and recreating it.
🐦‍⬛ Birdie snapshot test failed

❌ 
birdie_bug_test.a_test:14: Error: 
        False
        should equal 
        True

1 tests, 1 failures

The snapshot file's contents is actually correct since it works fine on the erlang target:

---
version: 1.1.0
title: a test
file: ./test/birdie_bug_test.gleam
test_name: a_test
---
a test

Reproduction

Test module:

import gleeunit
import birdie

pub fn main() {
  gleeunit.main()
}

pub fn a_test() {
  "a test"
  |> birdie.snap("a test")
}

Steps to reproduce:

  1. gleam test --target javascript (works fine)
  2. gleam run -m birdie -- accept-all (works fine)
  3. gleam test --target javascript (error occurs)
giacomocavalieri commented 8 months ago

You found a compiler bug! This will be ok once this issue is closed 😁

MystPi commented 8 months ago

Awesome! Thanks for all your work on the compiler!