docs/tests/fixtures
Rachael Sewell e6802bf875
data reference linter rules (#43406)
Co-authored-by: Peter Bengtsson <peterbe@github.com>
2023-10-05 21:42:01 +00:00
..
content fix incorrect code language case 2023-09-25 11:21:53 -07:00
data data reference linter rules (#43406) 2023-10-05 21:42:01 +00:00
liquid-tags Remove support versions: * (#40548) 2023-08-11 18:19:46 +00:00
products Migrate Actions Runner Controller docs (#35498) 2023-04-24 18:47:18 +00:00
translations/ja-jp Correct translation content from reusables too (#37722) 2023-06-13 11:49:18 +00:00
README.md fix incorrect code language case 2023-09-25 11:21:53 -07:00
article-with-introLinks.md Change product landing page `introLinks` to a general map of link titles to links (#26360) 2022-04-01 11:01:37 -05:00
article-with-mislocalized-frontmatter.md Remove versions feature flag code (#15793) 2020-09-29 13:36:07 -04:00
article-with-redirect-from-string.md Remove support versions: * (#40548) 2023-08-11 18:19:46 +00:00
article-with-videos.md Removing actions video (#34716) 2023-02-14 19:18:36 +00:00
changelog-feed.json cache changelog feed in CI (#25759) 2022-03-03 20:32:34 +00:00
default-tool.md remove tool-switcher (#24242) 2022-01-12 16:32:30 +00:00
developer-redirects.json Move events docs to API docs set (#41292) 2023-08-24 23:38:24 +00:00
feature-versions-frontmatter.md write tests to ensure that ghes versioning in a feature gets combined with ghes versioning frontmatter, and does NOT overwrite it 2021-06-23 15:03:12 -04:00
github-blog-feed-packages-2021.xml content unit tests shouldn't depend on github.blog (#23578) 2021-12-13 08:57:00 +00:00
graphql-redirects.json update tests to remove free-pro-team from expected results 2021-01-14 17:08:30 -05:00
page-that-does-not-exist-in-translations-dir.md Remove versions feature flag code (#15793) 2020-09-29 13:36:07 -04:00
page-versioned-for-all-enterprise-releases.md Support enterpriseServerVersions in Liquid statements (#16058) 2020-10-15 16:20:41 -04:00
page-versioned-for-next-enterprise-release.md add tests 2021-03-17 10:30:16 -04:00
page-with-frontmatter-error.md Remove versions feature flag code (#15793) 2020-09-29 13:36:07 -04:00
page-with-invalid-product-version.md Support GHAE internal-only semantic versioning (#29178) 2022-09-22 08:26:58 +02:00
page-with-missing-product-versions.md Hello git history spelunker! 2020-09-27 14:10:11 +02:00
page-with-optional-attributes.md an empty 'product', 'permissions', or 'learningTracks' gets stuck (#25070) 2022-02-07 16:08:51 +00:00
page-with-redirects.md 404 if the applicable version no longer matches (#33086) 2022-11-30 16:27:29 +00:00
rest-redirects.json Move events docs to API docs set (#41292) 2023-08-24 23:38:24 +00:00
rss-feed.xml Rename github-community to community 2022-07-27 17:36:23 -04:00
sample-article.md Remove versions feature flag code (#15793) 2020-09-29 13:36:07 -04:00
sample-toc-index.md Remove versions feature flag code (#15793) 2020-09-29 13:36:07 -04:00
short-versions.md support short versions in frontmatter 2021-06-14 19:51:38 -04:00
translated-toc-with-no-links-index.md Remove versions feature flag code (#15793) 2020-09-29 13:36:07 -04:00
versionless-redirects.txt [Improvement]: Review the policy content for Code security and analysis in the Enterprise docs (#42157) 2023-09-26 08:30:25 +00:00

README.md

Fixture content

Fixture content is content (and data) that is meant to look very similar to the real content, but exists for the benefit of testing functionality.

In its simplest form, code and content is intricately linked, and oftentimes to be able to have automated testing of functionality, you need some content to exercise that functionality.

Our fixture content exists so we can write and run end-to-end tests against content that is specifically tied to making sure the functionality sustainably works when we're changing any code, but without having to worry about the real English content breaking the tests.

Note! We also don't want the writers of the real English content to have to worry about breaking tests of functionality.

How to write fixtured based rendering tests

The content is in tests/fixtures/content/ (and tests/fixtures/data/) is a cut down version of the real content/ (and data/) at the root. It doesn't have nearly as many pages and if you look closely you'll see references and mentions to unrealistic things like "foo" or "HubGit" which are whimsical but also importantly different. If it works with any silly name, the code is modular and good.

Quickstart

Navigate around in tests/fixtures/content/ and familiarize yourself with the directory structure. The only things that are "identical" to the real content is the top-level product names which match the real content. Deeper than the product level, the names and directories can be whatever you want it to be.

Once you've found a place to put some fixture content, before writing a jest test, you can preview your changes using:

npm run fixture-dev

and navigate to http://localhost:4000 to see your fixture content in action.

Write the tests

Feel free to create sub-directories or new files. For example, if it's about end-to-end testing a new custom Liquid tag called lib/liquid-tags/snacks.js you create a new test called tests/rendering-fixtures/snack.js. (And equally, you might want to create tests/fixtures/content/get-started/foo/snacking.md)

To run the tests use:

ROOT=tests/fixtures jest tests/rendering-fixtures/

Exceptions

The top-level product names in the fixture content needs to be a perfect subset of the product names in the real content. That's because they get compiled in to the Next rewrite functionality so we can support URLs that actually are free-pro-team@latest without mentioning it in the URL.

Another exception is some data files that straddle real content and support functionality. For example, data/ui.yml is part of the functionality (e.g. React components) but lives in the data/ directory so its translation repos copies can be translated.

There's a script you can always run that makes sure all and any of these files are up to do:

./script/copy-fixture-data.js

It's safe to run any time. And it might be necessary to run so that the fixture data gets a fresh copy.

Tip! Own it

The advantage with fixture content for testing is that you can control it. It's less likely now that your tests break because of some other change. Similar to unit testing strategies, try to keep things in small units that worries about one thing at a time.

Don't be afraid to write a jest test that is very specific about what it tests. It might seem strange when someone is only reading the tests directly. But the fixtures are part of the tests. It's just in different files.