Skip to content

Commit

Permalink
chore(js,browser): improve lint comments in jest.setup.js (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
IceHe authored Feb 14, 2022
1 parent 2418193 commit 64e7434
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/browser/jest.setup.js
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 */
4 changes: 3 additions & 1 deletion packages/client/jest.setup.js
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 */

0 comments on commit 64e7434

Please sign in to comment.