-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(js,browser): improve lint comments in jest.setup.js (#176)
- Loading branch information
Showing
2 changed files
with
6 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
// Need to disable following rules to mock text-decode/text-encoder and crypto for jsdom | ||
// https://github.com/jsdom/jsdom/issues/1612 | ||
/* eslint-disable @silverhand/fp/no-mutation */ | ||
/* eslint-disable unicorn/prefer-module */ | ||
const crypto = require('crypto'); | ||
|
||
const { location } = require('jest-location-mock'); | ||
const { TextDecoder, TextEncoder } = require('text-encoder'); | ||
/* eslint-enable unicorn/prefer-module */ | ||
|
||
/* eslint-disable @silverhand/fp/no-mutation */ | ||
global.crypto = { | ||
getRandomValues: (buffer) => crypto.randomFillSync(buffer), | ||
subtle: crypto.webcrypto.subtle, | ||
}; | ||
global.location = location; | ||
global.TextDecoder = TextDecoder; | ||
global.TextEncoder = TextEncoder; | ||
/* eslint-enable @silverhand/fp/no-mutation */ |
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,12 +1,14 @@ | ||
// Need to disable following rulus to mock text-decode/text-encoder and crypto for jsdom | ||
// https://github.com/jsdom/jsdom/issues/1612 | ||
/* eslint-disable @silverhand/fp/no-mutation */ | ||
/* eslint-disable unicorn/prefer-module */ | ||
const { Crypto } = require('@peculiar/webcrypto'); | ||
const fetch = require('node-fetch'); | ||
const { TextDecoder, TextEncoder } = require('text-encoder'); | ||
/* eslint-enable unicorn/prefer-module */ | ||
|
||
/* eslint-disable @silverhand/fp/no-mutation */ | ||
global.crypto = new Crypto(); | ||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; | ||
global.fetch = fetch; | ||
/* eslint-enable @silverhand/fp/no-mutation */ |