Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
jest-remirror
Advanced tools
yarn add jest-remirror # yarn
pnpm add jest-remirror # pnpm
npm install jest-remirror # npm
For a quick setup add the following to your jest.config.js file.
/* jest.config.js */
module.exports = {
setupFilesAfterEnv: ['jest-remirror/environment'],
testEnvironment: 'jsdom', // Required for dom manipulation
};
This will automatically
toEqualRemirrorDocument
and toMatchRemirrorSnapshot
.If you are using typescript then add this to your tsconfig.json
file for global type support.
{
"compilerOptions": {
"types": ["jest-remirror"]
}
}
Create a jest.framework.dom.ts
file and add the following
/* jest.framework.dom.ts */
import { jsdomPolyfill, remirrorMatchers } from 'jest-remirror';
/* Add jest-remirror assertions */
expect.extend(remirrorMatchers);
/* Polyfills for jsdom */
jsdomPolyfill();
In your jest.config.js
file add this to the configuration
/* jest.config.js */
module.exports = {
setupFilesAfterEnv: ['<rootDir>/jest.framework.dom.ts'],
testEnvironment: 'jsdom', // Required for dom manipulation
};
Testing contenteditable is really difficult, especially with jsdom
. There are certain events that can't be fired and it's often hard to conceptualize how the test result translates to the actual user experience.
jest-remirror
makes rendering the remirror editor painless so that you can test that your extensions:
Under the hood jest-remirror
leans heavily on @remirror/dom
to render an instance of your test editor to the dom and provides a number of utilities exposed when calling the renderEditor
method.
import { renderEditor } from 'jest-remirror';
import { EmojiExtension } from '@remirror/extension-emoji';
test('emoticons replaced with emoji', () => {
const {
nodes: { p, doc },
add,
} = renderEditor({ plainNodes: [], others: [new EmojiExtension()] });
add(doc(p('<cursor>')))
.insertText(':-)')
.callback((content) => {
expect(content.state.doc).toEqualRemirrorDocument(doc(p('😃')));
});
});
This package borrows very heavily from @atlaskit/editor-test-helpers
FAQs
A text editor for react built with prosemirror
The npm package jest-remirror receives a total of 1,803 weekly downloads. As such, jest-remirror popularity was classified as popular.
We found that jest-remirror demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.