Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run tests in isolation #332

Merged
merged 10 commits into from
Jan 19, 2023
Merged

Conversation

brkalow
Copy link
Contributor

@brkalow brkalow commented Jan 19, 2023

Builds off of #331

Refactors integration tests to run against isolated fixtures. This is accomplished by copying the fixtures defined in __tests__/fixtures into tmp directories and doing a clean install of a locally packed next-mdx-remote, along with next, react, and react-dom. This ensures each test case is independently executed and by relying on npm pack we are testing against the eventually published artifact.

We now expose a createDescribe test utility that handles creating an isolated directory from one of our fixtures:

import { createDescribe } from '../.jest/utils'

createDescribe('hydration', { fixture: 'basic' }, ({ dir, browser }) => {
	test('something', () => { ... })
})

h/t to @timneutkens for pointing me at Next.js's testing approach, which this is inspired by 🙏

brkalow and others added 4 commits January 18, 2023 18:34

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@brkalow brkalow changed the title chore: move code around, make test fixtures import from next-mdx-remote chore: run tests in isolation Jan 19, 2023
@brkalow brkalow requested a review from a team January 19, 2023 00:44
@brkalow brkalow marked this pull request as ready for review January 19, 2023 00:52
@timneutkens
Copy link
Contributor

Looks good to me!

@@ -0,0 +1,32 @@
---
title: 'foo'
name: jeff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

Comment on lines +99 to +106
fn({
dir() {
return tmpDir
},
browser() {
return browser
},
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

Copy link
Contributor

@thiskevinwang thiskevinwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
👏 Very cool new testing pattern here.

@brkalow brkalow merged commit b3f026b into main Jan 19, 2023
@brkalow brkalow deleted the brk.feat/repo-structure-refactor-tests branch January 19, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants