Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
{
"name": "@nemrosim/npm-package-example",
"version": "1.0.0",
+ "description": "Some description",
"repository": {
"type": "git",
"url": "https://github.com/nemrosim/npm-package-create-test-deploy-examples"
- }
+ },
+ "bugs": {
import React from 'react';
import { render, screen } from '@testing-library/react';
import { App } from './App';
// ... other tests
describe('diff approaches', () => {
// helper
function textContentMatcher(text) {
return function (_content, node) {
const sameImage = screen.getByAltText('logo');
expect(sameImage).toBeInTheDocument();
});
+
+it('should render paragraph with text', () => {
+ render(<App />);
+
+ expect(
+ screen.getByText('Edit src/App.tsx and save to reload.'),
+ ).toBeInTheDocument();
import React from 'react';
import { render, screen } from '@testing-library/react';
import { App } from './App';
it('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
import React from 'react';
import logo from './logo.svg';
import './App.css';
export const App = () => (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
import React from 'react';
export const withSomething = (WrappedComponent, context) => {
return (props) => {
return <WrappedComponent/>;
}
};
-import React, { useEffect, useState } from 'react';
+import React, { useCallback, useEffect, useState } from 'react';
import { I18nProvider as LinguiI18nProvider } from "@lingui/react";
import { i18n } from "@lingui/core";
+import {
+ detect,
+ fromCookie,
+ fromHtmlTag,
+ fromNavigator,
+ fromPath,
import React from "react";
-import { Plural } from "@lingui/macro";
+import { Plural, plural } from "@lingui/macro";
export const JSXPlurals: React.FC = () => {
const amountList = [ 0, 1, 2, 5, 100 ]
+ const jsMacrosExample = (amount: number) => plural(amount, {
+ one: "You got {amount} item (one)",