Skip to content
Myr

Add Jest note

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrey Sitnik · committed by Andrey Sitnik · parent fd80ce3 · Browse files · 2 files+34 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+34 added−0 removed

  • other:+34 added−0 removed

2 files+34 added−0 removed

modified:README.md+17 added
49 unmodified lines
50 * [React](#react)51 * [React Native](#react-native)52 * [PouchDB and CouchDB](#pouchdb-and-couchdb)53 * [Web Workers](#web-workers)54 * [Jest](#jest)55 * [CLI](#cli)56 * [Other Programming Languages](#other-programming-languages)57* [Tools](#tools)58
347 unmodified lines
406407Note: non-secure IDs are more prone to collision attacks.408409410### Jest411412Jest test runner with `jest-environment-jsdom` will use browser’s version413of Nano ID. You will need polyfill for Web Crypto API.414415```js416import { randomFillSync } from 'crypto'417418window.crypto = {419 getRandomValues(buffer) {420 return randomFillSync(buffer)421 }422}423```424425426### CLI427428You can get unique ID in terminal by calling `npx nanoid`. You need only429Node.js in the system. You do not need Nano ID to be installed anywhere.
70 unmodified lines
modified:README.ru.md+17 added
53 unmodified lines
54 - [React](#react)55 - [React Native](#react-native)56 - [PouchDB и CouchDB](#pouchdb-и-couchdb)57 - [Веб-воркеры](#веб-воркеры)58 - [Jest](#jest)59 - [Терминал](#терминал)60 - [Другие языки программирования](#другие-языки-программирования)61- [Инструменты](#инструменты)62
330 unmodified lines
393nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"394```395396397### Jest398399Фреймворк тестов Jest со средой `jest-environment-jsdom` будет использовать400браузерную версию Nano ID. Ва понадобится полифил для Web Crypto API.401402```js403import { randomFillSync } from 'crypto'404405window.crypto = {406 getRandomValues(buffer) {407 return randomFillSync(buffer)408 }409}410```411412413### Терминал414415Можно сгенерировать уникальный ID прямо из терминала, вызвав `npx nanoid`.416Для этого в системе должна быть только Node.js. `npx` сама скачает Nano ID,
70 unmodified lines