Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: migrate to typescript #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SimenB wants to merge 4 commits into master
base: master
Choose a base branch
Loading
from typescript
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules
flow-typed
build
3 changes: 1 addition & 2 deletions .eslintrc.json
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"extends": "@callstack",
"rules": {
"global-require": 0,
"flowtype/no-weak-types": 0,
"strict": [0, "global"],
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"react-native/no-raw-text": 0
}
}
2 changes: 0 additions & 2 deletions .flowconfig
View file Open in desktop

This file was deleted.

1 change: 0 additions & 1 deletion .npmignore
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
src
__tests__
flow-typed
yarn.lock
.eslintcache
6 changes: 2 additions & 4 deletions __tests__/getSnapshotDiffSerializer.test.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// @flow
const { snapshotDiff, getSnapshotDiffSerializer } = require('../src/index');

const snapshotDiff = require('../src/index');
// $FlowFixMe – wrong type declaration in flow-typed/jest@20.x.x
expect.addSnapshotSerializer(snapshotDiff.getSnapshotDiffSerializer());
expect.addSnapshotSerializer(getSnapshotDiffSerializer());

test('serialize text diff output', () => {
expect(
Expand Down
9 changes: 3 additions & 6 deletions __tests__/index.test.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
test('public api', () => {
const index = require('../src/index');
const index = require('../build/index');

expect(index).toBeInstanceOf(Function);
expect(index.snapshotDiff).toBe(index);
expect(index.snapshotDiff).toBeInstanceOf(Function);
expect(index.toMatchDiffSnapshot).toBeInstanceOf(Function);
expect(index.getSnapshotDiffSerializer).toBeInstanceOf(Function);

const {
snapshotDiff,
toMatchDiffSnapshot,
getSnapshotDiffSerializer,
} = require('../src/index');
} = require('../build/index');

expect(snapshotDiff).toBe(index);
expect(toMatchDiffSnapshot).toBe(index.toMatchDiffSnapshot);
expect(getSnapshotDiffSerializer).toBe(index.getSnapshotDiffSerializer);
});
15 changes: 7 additions & 8 deletions __tests__/setSerializers.test.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// @flow
const React = require('react');
const { configure, shallow: enzymeShallow } = require('enzyme');
const ReactShallowRenderer = require('react-test-renderer/shallow');
const Adapter = require('enzyme-adapter-react-16');
const enzymeToJson = require('enzyme-to-json/serializer');
const snapshotDiff = require('../src/index');
const {
snapshotDiff,
setSerializers,
defaultSerializers,
} = require('../src/index');

configure({ adapter: new Adapter() });
const reactShallow = new ReactShallowRenderer();

snapshotDiff.setSerializers([...snapshotDiff.defaultSerializers, enzymeToJson]);

type Props = {
test: string,
};
setSerializers([...defaultSerializers, enzymeToJson]);

const Component = ({ value }) => <div>I have value {value}</div>;

const NestedComponent = (props: Props) => (
const NestedComponent = (props) => (
<div>
<span>Hello World - {props.test}</span>
<Component value={1234} />
Expand Down
17 changes: 3 additions & 14 deletions __tests__/snapshotDiff.test.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// @flow

/* eslint-disable react/no-multi-comp */

const React = require('react');
const snapshotDiff = require('../src/index');
const { snapshotDiff } = require('../src/index');

const a = `
some
Expand Down Expand Up @@ -78,15 +76,7 @@ const noIndentB = `
@script
`;

type Props = {
test?: string,
unnamedFunction?: () => void,
unnamedJestMock?: () => void,
namedJestMock?: () => void,
withSecond?: boolean,
};

class Component extends React.Component<Props> {
class Component extends React.Component {
render() {
return (
<div>
Expand Down Expand Up @@ -171,7 +161,7 @@ class Component extends React.Component<Props> {
}
}

class FragmentComponent extends React.Component<Props> {
class FragmentComponent extends React.Component {
render() {
return (
<>
Expand Down Expand Up @@ -254,7 +244,6 @@ test('can use stablePatchmarks on diff', () => {
describe('failed optional deps', () => {
beforeEach(() => {
jest.mock('react-test-renderer', () => {
// $FlowFixMe -- this is intended.
require('non-existent-module-for-testing'); // eslint-disable-line
});
});
Expand Down
7 changes: 1 addition & 6 deletions __tests__/toMatchDiffSnapshot.test.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

const snapshotDiff = require('../src/index');

const a = `
Expand Down Expand Up @@ -35,18 +33,15 @@ beforeAll(() => {
});

test('works with default options', () => {
// $FlowFixMe
expect(a).toMatchDiffSnapshot(b);
});

[{ expand: true }, { contextLines: 0 }].forEach((options: any) => {
[{ expand: true }, { contextLines: 0 }].forEach((options) => {
test(`proxies "${Object.keys(options).join(', ')}" option(s)`, () => {
// $FlowFixMe
expect(a).toMatchDiffSnapshot(b, options);
});
});

test('works with custom name', () => {
// $FlowFixMe
expect(a).toMatchDiffSnapshot(b, {}, 'slim');
});
2 changes: 1 addition & 1 deletion babel.config.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
presets: [
'@babel/preset-react',
'@babel/preset-flow',
'@babel/preset-typescript',
['@babel/preset-env', { targets: { node: '12' } }],
],
};
Loading

AltStyle によって変換されたページ (->オリジナル) /