-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(#zimic): upgrade msw to v2.7.0 (#423)
- Loading branch information
1 parent
c5b95cf
commit 2a60673
Showing
6 changed files
with
484 additions
and
182 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
import mswPackageJSON from 'msw/package.json'; | ||
import filesystem from 'fs/promises'; | ||
import path from 'path'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { postinstallPromise } from '../postinstall'; | ||
import { MSW_PACKAGE_PATH, MSW_BROWSER_DIRECTORY, MSWPackage, postinstallPromise } from '../postinstall'; | ||
|
||
describe('Post-install script', () => { | ||
it('should remove the default MSW export limitations after installation', async () => { | ||
it('should patch msw/package.json exports', async () => { | ||
await postinstallPromise; | ||
|
||
const { exports } = mswPackageJSON; | ||
const mswPackageContentAsString = await filesystem.readFile(MSW_PACKAGE_PATH, 'utf-8'); | ||
const mswPackageContent = JSON.parse(mswPackageContentAsString) as MSWPackage; | ||
|
||
const { exports } = mswPackageContent; | ||
|
||
expect(exports['./browser'].node).toEqual(exports['./node'].node); | ||
expect(exports['./node'].browser).toEqual(exports['./browser'].browser); | ||
}); | ||
|
||
it.each(['index.js', 'index.mjs'])( | ||
'should patch a missing undefined check in msw/browser/%s', | ||
async (indexFileName) => { | ||
await postinstallPromise; | ||
|
||
const mswBrowserPath = path.join(MSW_BROWSER_DIRECTORY, indexFileName); | ||
const mswBrowserContent = await filesystem.readFile(mswBrowserPath, 'utf-8'); | ||
|
||
expect(mswBrowserContent).toContain('if (!request || responseJson.type?.includes("opaque")) {'); | ||
}, | ||
); | ||
}); |
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
Oops, something went wrong.