This doc states the following:

If you happen to modify the public API of Angular, API golden files must be updated using...

Also this commit has the following heading:

fix: public API golden files #16414

I'm wondering what is usually referred to as "golden files". I've googled around and it seems that this phrase is commonly used.

  • lists.boost.org/boost-users/2013/04/78334.php. It's for some specific tests, where you compare the output of a test to a specific file.
    – Walfrat
    Oct 8, 2017 at 10:23
  • 1
    In my neck of the woods, we refer to them as "baselines". When a test changes, or an implementation changes, we have to update the baselines to be in line with the new tests or implementations. Oct 12, 2017 at 5:05

3 Answers 3


A "golden file" is the expected output of some test (usually automated), stored as a separate file rather than as a string literal inside the test code. So when the test is executed, it will read in the file and compare it to the output produced by the system under test.

It's not really a very common expression; I have not heard it in 15 years of professional programming, even though I have used such files many times.

  • 1
    what is the common name to describe these files?
    – cowlinator
    Dec 10, 2019 at 3:38
  • 2
    @cowlinator: I don't think there really is one. I just thought of them as "expected output". Dec 10, 2019 at 7:28
  • 2
    A related term I'm familiar with is 'golden data'. This refers to test data that doesn't change. This input is expected to produce the same (or very similar output) when used in a regression test. The term 'golden' probably comes from the fact that gold is a stable substance.
    – JimmyJames
    Jan 29, 2020 at 16:18
  • 4
    In electronics manufacturing, a 'golden unit' is the best prototype or one of the best/most typical units from the first production run that is set aside for verifying test procedures and for comparing with future units. Jan 30, 2020 at 16:57
  • 1
    Honestly it is a fairly common expression for those working with Golang. It’s a pattern used in the Go standard library (as referenced here and here)
    – tdensmore
    Dec 10, 2022 at 14:54

In a nutshell, a golden file is a file where we store the output and that will be used by the test as the expected output. This file should be updated any time the output changes for good reason. That's that simple :) .

Once again, introducing and using golden files in our tests is pretty straightforward and easy to use.

I got this useful link.


I think this is also known as "snapshot testing" in some contexts (if not all).

Some references:

  • 1
    Great that you introduce an other often used term for the concept of "golden files", this can help the asker to answer their question. Great that you provide some links with more information. I think you can improve your answer even more by a (brief) description of what "golden files"/"snapshot testing" is. Stack overflow is often the first result that pops-up in google and it would be great if people can immediatly learn from your answer what "golden files" are. It also helps when the linked sited change or go down. Oct 31, 2022 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.