Created
April 28, 2023 18:54
-
-
Save epreston/3922c1b6a5aa617790f6e31578bf63eb to your computer and use it in GitHub Desktop.
vitest - example test file structure for browser context testing with jsdom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @vitest-environment jsdom | |
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; | |
// --------------------------------------------------------- | |
// import { itemsToMock } from '../src/testDependency.js'; | |
// --------------------------------------------------------- | |
// vi.mock('../src/testDependency.js'); | |
// --------------------------------------------------------- | |
// import { itemBeingTested } from '../src/testTarget.js'; | |
// --------------------------------------------------------- | |
describe('JSDom Test Environment', () => { | |
it('is working as expected', () => { | |
expect(document).toBeDefined(); | |
expect(window).toBeDefined(); | |
const divEl = document.createElement('div'); | |
expect(divEl).toBeDefined(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment