Skip to content

Commit cef98b8

Browse files
committed
Fix all typescript errors
1 parent 56360e4 commit cef98b8

30 files changed

+106
-100
lines changed

src/__tests__/actions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
scrollTo,
66
scrollToEnd,
77
toExist,
8-
} from './actions';
9-
import * as websocket from './websocket';
8+
} from '../actions';
9+
import * as websocket from '../websocket';
1010

1111
describe('actions.ts', () => {
1212
let onMessageCallback: (onMessage: (message: string) => void) => void;

src/__tests__/cli/build.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import path from 'path';
2-
import execa from 'execa';
2+
import * as execa from 'execa';
33

4-
import { buildAndroid, buildHandler, buildIOS, ENTRY_FILE } from './build';
5-
import { CliBuildOptions, Config, ConfigEnv } from '../types';
6-
import { Logger } from '../logger';
7-
import * as configHelpers from './config';
4+
import { buildAndroid, buildHandler, buildIOS, ENTRY_FILE } from '../../cli/build';
5+
import type { CliBuildOptions, Config, ConfigEnv } from '../../types';
6+
import { Logger } from '../../logger';
7+
import * as configHelpers from '../../cli/config';
88

99
describe('build.ts', () => {
1010
const logger = new Logger();
11-
const execMock = jest.spyOn(execa, 'command').mockImplementation();
11+
const execMock = jest.spyOn(execa, 'execaCommand').mockImplementation();
1212

1313
beforeEach(() => {
1414
execMock.mockReset();

src/__tests__/cli/config.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises as fs } from 'fs';
22

3-
import { Config } from '../types';
4-
import { getConfig, readConfigFile, validateSchema } from './config';
3+
import type { Config } from '../../types';
4+
import { getConfig, readConfigFile, validateSchema } from '../../cli/config';
55

66
describe('config.ts', () => {
77
describe('validateSchema', () => {

src/__tests__/cli/run.test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { promises as fs } from 'fs';
22
import path from 'path';
3-
import * as reportHelpers from '../report';
4-
import * as configHelpers from './config';
3+
import * as reportHelpers from '../../report';
4+
import * as configHelpers from '../../cli/config';
55

6-
import { CliRunOptions, Config } from '../types';
7-
import * as run from './run';
8-
import * as xcrun from '../utils/xcrun';
9-
import * as adb from '../utils/adb';
10-
import execa from 'execa';
11-
import { Logger } from '../logger';
6+
import type { CliRunOptions, Config } from '../../types';
7+
import * as run from '../../cli/run';
8+
import * as xcrun from '../../utils/xcrun';
9+
import * as adb from '../../utils/adb';
10+
import * as execa from 'execa';
11+
import { execaCommand } from 'execa';
12+
import { Logger } from '../../logger';
1213

1314
jest.mock('../../utils/xcrun');
1415
jest.mock('../../utils/adb');
@@ -21,9 +22,9 @@ describe('run.ts', () => {
2122
const mkdirMock = jest.spyOn(fs, 'mkdir');
2223
const execKillMock = {
2324
kill: jest.fn(),
24-
} as unknown as execa.ExecaChildProcess<any>;
25+
} as unknown as ReturnType<typeof execaCommand>;
2526

26-
const execMock = jest.spyOn(execa, 'command').mockImplementation();
27+
const execMock = jest.spyOn(execa, 'execaCommand').mockReturnValue(execKillMock);
2728

2829
beforeEach(() => {
2930
mkdirMock.mockReset();
@@ -153,7 +154,7 @@ describe('run.ts', () => {
153154
process.cwd()
154155
)} --runInBand`;
155156

156-
const commandSyncMock = jest.spyOn(execa, 'commandSync');
157+
const commandSyncMock = jest.spyOn(execa, 'execaCommandSync');
157158
const mockGenerateReport = jest.spyOn(reportHelpers, 'generateReport');
158159

159160
jest.spyOn(Logger.prototype, 'print').mockImplementation();
@@ -245,7 +246,7 @@ describe('run.ts', () => {
245246

246247
await run.runHandler({ ...args });
247248

248-
await expect(execMock.mock.calls[0][0]).toEqual(
249+
await expect(execMock.mock.calls[0]?.[0]).toEqual(
249250
'node scripts/websocket-server.js'
250251
);
251252
});

src/__tests__/client/handleAction.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Logger } from '../logger';
2-
import { handleAction } from './handleAction';
1+
import { Logger } from '../../logger';
2+
import { handleAction } from '../../client/handleAction';
33

44
describe('handleAction.ts', () => {
55
const logger = new Logger(false);

src/__tests__/client/trackedElements.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Logger } from '../logger';
2-
import { add, get } from './trackedElements';
1+
import { Logger } from '../../logger';
2+
import { add, get } from '../../client/trackedElements';
33

44
describe('trackedElements.ts', () => {
55
const logger = new Logger(false);

src/__tests__/client/websocket.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Logger } from '../logger';
1+
import { Logger } from '../../logger';
22
import WS from 'jest-websocket-mock';
3-
import { WEBSOCKET_PORT } from '../constants';
4-
import { ANDROID_WS_HOST, IOS_WS_HOST } from './constants';
3+
import { WEBSOCKET_PORT } from '../../constants';
4+
import { ANDROID_WS_HOST, IOS_WS_HOST } from '../../client/constants';
55

66
describe('websocket.ts', () => {
77
const logger = new Logger(false);

src/__tests__/logger.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Logger } from './logger';
1+
import { Logger } from '../logger';
22

33
describe('logger.ts', () => {
44
const logMessage = 'Hello World';

src/__tests__/matchers.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import fs from 'fs';
22
import pixelmatch from 'pixelmatch';
3-
import { mocked } from 'ts-jest/utils';
3+
import { mocked } from 'jest-mock';
44

5-
import { toMatchBaseline } from './matchers';
5+
import { toMatchBaseline } from '../matchers';
66

77
jest.mock('pixelmatch');
88

99
describe('matchers.ts', () => {
10-
const mockedPixelmatch = mocked(pixelmatch, true);
10+
const mockedPixelmatch = mocked(pixelmatch, { shallow: false });
1111

1212
const imageHello1Data = `iVBORw0KGgoAAAANSUhEUgAAACUAAAALCAYAAAD4OERFAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAJaADAAQAAAABAAAACwAAAADN8bJQAAABcElEQVQ4Ec2UvytGURjHr1/lHd5JlF9leMNAiQzKbqCMBt5ikUEWMhkMDGZ/gEHZDMqCsr6JQel9yW8Dg4lBJvL5ck7dTudw3UG+9el5nvM859znnnPujaIoKoMq+Ffqo5uTFB1dMacLuuEixXxNaYRNd26lO/BHcZbnjEEecu4zy82AjnARbuEIOsBqEqdkmLGDAav1luAB7mEBtLYrNdUKd27Cxjq+d1iFTtiALZCG4QYGQLlTGAXJd3zTjB9CM7SB6schpF4Sj76kmnoCu2v9+OemcBc7Z3yZKbAN+5o6Jj+hQiM1uWMDj/U2Ze+Utlu7Jb1A5tP7Om9NnDexvtIz4/tMC4MHscQ1fm0sTuTa3XkLVD8zrretM9RjByGkIommWFJHWIjFiVzbVKh4n8QIVBvWsLMQ0jaJPKheF3wI9uBX+qmpZVarAV12fSnyVyCkdRI9cAm65K/w3Z0inU56Y/1LRBJVUNQODUmKfTUfKJc7FJ+heOgAAAAASUVORK5CYII=`;
1313
const imageHello1Buffer = Buffer.from(imageHello1Data, 'base64');

src/__tests__/report.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import process from 'process';
22
import handlebars from 'handlebars';
33
import { promises as fs } from 'fs';
4-
import * as fileExists from './utils/file-exists';
4+
import * as fileExists from '../utils/file-exists';
55

6-
import { Logger } from './logger';
7-
import { generateReport } from './report';
6+
import { Logger } from '../logger';
7+
import { generateReport } from '../report';
88

99
describe('report.ts', () => {
1010
const logger = new Logger();

0 commit comments

Comments
 (0)