();
const resolved = dependencyResolver.resolveInverse(paths, filter);
- expect(resolved.length).toEqual(0);
+ expect(resolved.length).toBe(0);
});
test('resolves no inverse dependencies for set of non-existent paths', () => {
const paths = new Set(['/non/existent/path', '/another/one']);
const resolved = dependencyResolver.resolveInverse(paths, filter);
- expect(resolved.length).toEqual(0);
+ expect(resolved.length).toBe(0);
});
test('resolves inverse dependencies for existing path', () => {
diff --git a/packages/jest-resolve/src/__tests__/resolve.test.ts b/packages/jest-resolve/src/__tests__/resolve.test.ts
index 2b6505cef014..2b85fe4aaa7c 100644
--- a/packages/jest-resolve/src/__tests__/resolve.test.ts
+++ b/packages/jest-resolve/src/__tests__/resolve.test.ts
@@ -53,21 +53,21 @@ describe('isCoreModule', () => {
hasCoreModules: false,
} as ResolverConfig);
const isCore = resolver.isCoreModule('assert');
- expect(isCore).toEqual(false);
+ expect(isCore).toBe(false);
});
it('returns true if `hasCoreModules` is true and `moduleName` is a core module.', () => {
const moduleMap = ModuleMap.create('/');
const resolver = new Resolver(moduleMap, {} as ResolverConfig);
const isCore = resolver.isCoreModule('assert');
- expect(isCore).toEqual(true);
+ expect(isCore).toBe(true);
});
it('returns false if `hasCoreModules` is true and `moduleName` is not a core module.', () => {
const moduleMap = ModuleMap.create('/');
const resolver = new Resolver(moduleMap, {} as ResolverConfig);
const isCore = resolver.isCoreModule('not-a-core-module');
- expect(isCore).toEqual(false);
+ expect(isCore).toBe(false);
});
it('returns false if `hasCoreModules` is true and `moduleNameMapper` alias a module same name with core module', () => {
@@ -81,21 +81,21 @@ describe('isCoreModule', () => {
],
} as ResolverConfig);
const isCore = resolver.isCoreModule('constants');
- expect(isCore).toEqual(false);
+ expect(isCore).toBe(false);
});
it('returns true if using `node:` URLs and `moduleName` is a core module.', () => {
const moduleMap = ModuleMap.create('/');
const resolver = new Resolver(moduleMap, {} as ResolverConfig);
const isCore = resolver.isCoreModule('node:assert');
- expect(isCore).toEqual(true);
+ expect(isCore).toBe(true);
});
it('returns false if using `node:` URLs and `moduleName` is not a core module.', () => {
const moduleMap = ModuleMap.create('/');
const resolver = new Resolver(moduleMap, {} as ResolverConfig);
const isCore = resolver.isCoreModule('node:not-a-core-module');
- expect(isCore).toEqual(false);
+ expect(isCore).toBe(false);
});
});
@@ -301,7 +301,7 @@ describe('findNodeModule', () => {
conditions: [],
});
- expect(result).toEqual(null);
+ expect(result).toBeNull();
});
test('fails if own pkg.json with no exports', () => {
@@ -313,7 +313,7 @@ describe('findNodeModule', () => {
conditions: [],
});
- expect(result).toEqual(null);
+ expect(result).toBeNull();
});
});
});
diff --git a/packages/jest-runtime/src/__tests__/runtime_create_mock_from_module.test.js b/packages/jest-runtime/src/__tests__/runtime_create_mock_from_module.test.js
index 453162978142..6fb9c046c4ca 100644
--- a/packages/jest-runtime/src/__tests__/runtime_create_mock_from_module.test.js
+++ b/packages/jest-runtime/src/__tests__/runtime_create_mock_from_module.test.js
@@ -36,7 +36,7 @@ describe('Runtime', () => {
const mock = module.jest.createMockFromModule('ModuleWithSideEffects');
// Make sure we get a mock.
- expect(mock.fn()).toBe(undefined);
+ expect(mock.fn()).toBeUndefined();
expect(module.getModuleStateValue()).toBe(origModuleStateValue);
});
diff --git a/packages/jest-runtime/src/__tests__/runtime_jest_fn.js b/packages/jest-runtime/src/__tests__/runtime_jest_fn.js
index 2cc2552ec529..705fe1fc10c7 100644
--- a/packages/jest-runtime/src/__tests__/runtime_jest_fn.js
+++ b/packages/jest-runtime/src/__tests__/runtime_jest_fn.js
@@ -31,7 +31,7 @@ describe('Runtime', () => {
const mock = root.jest.fn(string => `${string} implementation`);
expect(mock._isMockFunction).toBe(true);
const value = mock('mock');
- expect(value).toEqual('mock implementation');
+ expect(value).toBe('mock implementation');
expect(mock).toBeCalled();
});
});
diff --git a/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js b/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js
index 1c06c63b7ee4..8c3e3a32ee3f 100644
--- a/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js
+++ b/packages/jest-runtime/src/__tests__/runtime_module_directories.test.js
@@ -37,7 +37,7 @@ describe('Runtime', () => {
moduleDirectories,
});
const exports = runtime.requireModule(runtime.__mockRootPath, 'my-module');
- expect(exports.isNodeModule).toEqual(true);
+ expect(exports.isNodeModule).toBe(true);
});
it('finds closest module from moduleDirectories', async () => {
@@ -46,9 +46,7 @@ describe('Runtime', () => {
path.join(rootDir, 'subdir2', 'my_module.js'),
'module_dir_module',
);
- expect(exports.modulePath).toEqual(
- 'subdir2/module_dir/module_dir_module.js',
- );
+ expect(exports.modulePath).toBe('subdir2/module_dir/module_dir_module.js');
});
it('only checks the configured directories', async () => {
diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js
index ea1859daf358..d3cdb864bf9c 100644
--- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js
+++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js
@@ -83,7 +83,7 @@ describe('Runtime requireModule', () => {
runtime.__mockRootPath,
'inner_parent_module',
);
- expect(exports.outputString).toEqual('This should happen');
+ expect(exports.outputString).toBe('This should happen');
});
it('resolve module.parent.filename correctly', async () => {
@@ -93,7 +93,7 @@ describe('Runtime requireModule', () => {
'inner_parent_module',
);
- expect(slash(exports.parentFileName.replace(__dirname, ''))).toEqual(
+ expect(slash(exports.parentFileName.replace(__dirname, ''))).toBe(
'/test_root/inner_parent_module.js',
);
});
@@ -106,9 +106,9 @@ describe('Runtime requireModule', () => {
);
// `exports.loaded` is set while the module is loaded, so should be `false`
- expect(exports.loaded).toEqual(false);
+ expect(exports.loaded).toBe(false);
// After the module is loaded we can query `module.loaded` again, at which point it should be `true`
- expect(exports.isLoaded()).toEqual(true);
+ expect(exports.isLoaded()).toBe(true);
});
it('provides `module.filename` to modules', async () => {
diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js
index 3eaae70ec7e6..1eec78350149 100644
--- a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js
+++ b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock.test.js
@@ -153,7 +153,7 @@ it('automocking is disabled by default', async () => {
runtime.__mockRootPath,
'RegularModule',
);
- expect(exports.setModuleStateValue._isMockFunction).toBe(undefined);
+ expect(exports.setModuleStateValue._isMockFunction).toBeUndefined();
});
it('unmocks modules in config.unmockedModulePathPatterns for tests with automock enabled when automock is false', async () => {
diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js
index d555f104804f..fb88c96e4a06 100644
--- a/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js
+++ b/packages/jest-runtime/src/__tests__/runtime_require_module_or_mock_transitive_deps.test.js
@@ -29,8 +29,8 @@ describe('transitive dependencies', () => {
const expectUnmocked = nodeModule => {
const moduleData = nodeModule();
expect(moduleData.isUnmocked()).toBe(true);
- expect(moduleData.transitiveNPM3Dep).toEqual('npm3-transitive-dep');
- expect(moduleData.internalImplementation()).toEqual('internal-module-code');
+ expect(moduleData.transitiveNPM3Dep).toBe('npm3-transitive-dep');
+ expect(moduleData.internalImplementation()).toBe('internal-module-code');
};
it('mocks a manually mocked and mapped module', async () => {
@@ -73,7 +73,7 @@ describe('transitive dependencies', () => {
runtime.__mockRootPath,
'npm3-transitive-dep',
);
- expect(transitiveDep()).toEqual(undefined);
+ expect(transitiveDep()).toBeUndefined();
});
it('unmocks transitive dependencies in node_modules when using unmock', async () => {
@@ -98,7 +98,7 @@ describe('transitive dependencies', () => {
runtime.__mockRootPath,
'npm3-transitive-dep',
);
- expect(transitiveDep()).toEqual(undefined);
+ expect(transitiveDep()).toBeUndefined();
});
it('unmocks transitive dependencies in node_modules by default when using both patterns and unmock', async () => {
@@ -124,7 +124,7 @@ describe('transitive dependencies', () => {
runtime.__mockRootPath,
'npm3-transitive-dep',
);
- expect(transitiveDep()).toEqual(undefined);
+ expect(transitiveDep()).toBeUndefined();
});
it('mocks deep dependencies when using unmock', async () => {
diff --git a/packages/jest-snapshot/src/__tests__/dedentLines.test.ts b/packages/jest-snapshot/src/__tests__/dedentLines.test.ts
index 429b74fec8da..c09175efaf0d 100644
--- a/packages/jest-snapshot/src/__tests__/dedentLines.test.ts
+++ b/packages/jest-snapshot/src/__tests__/dedentLines.test.ts
@@ -130,7 +130,7 @@ describe('dedentLines null', () => {
['object value multi-line', {key: 'multi\nline\nvalue'}],
['object key and value multi-line', {'multi\nline': '\nleading nl'}],
])('%s', (name, val) => {
- expect(dedentLines(formatLines2(val))).toEqual(null);
+ expect(dedentLines(formatLines2(val))).toBeNull();
});
test('markup prop multi-line', () => {
@@ -145,7 +145,7 @@ describe('dedentLines null', () => {
};
const indented = formatLines2(val);
- expect(dedentLines(indented)).toEqual(null);
+ expect(dedentLines(indented)).toBeNull();
});
test('markup prop component with multi-line text', () => {
@@ -178,7 +178,7 @@ describe('dedentLines null', () => {
};
const indented = formatLines2(val);
- expect(dedentLines(indented)).toEqual(null);
+ expect(dedentLines(indented)).toBeNull();
});
test('markup text multi-line', () => {
@@ -205,7 +205,7 @@ describe('dedentLines null', () => {
};
const indented = formatLines2(val);
- expect(dedentLines(indented)).toEqual(null);
+ expect(dedentLines(indented)).toBeNull();
});
test('markup text multiple lines', () => {
@@ -232,18 +232,18 @@ describe('dedentLines null', () => {
};
const indented = formatLines2(val);
- expect(dedentLines(indented)).toEqual(null);
+ expect(dedentLines(indented)).toBeNull();
});
test('markup unclosed self-closing start tag', () => {
const indented = [' {
const indented = ['', ' Delightful JavaScript testing'];
- expect(dedentLines(indented)).toEqual(null);
+ expect(dedentLines(indented)).toBeNull();
});
});
diff --git a/packages/jest-util/src/__tests__/createProcessObject.test.ts b/packages/jest-util/src/__tests__/createProcessObject.test.ts
index 20ad012fc31b..c521ea25263c 100644
--- a/packages/jest-util/src/__tests__/createProcessObject.test.ts
+++ b/packages/jest-util/src/__tests__/createProcessObject.test.ts
@@ -59,13 +59,13 @@ it('checks that process.env works as expected on Linux platforms', () => {
expect(fake.PROP_UNDEFINED).toBe('undefined');
// Mac and Linux are case sensitive.
- expect(fake.PROP_string).toBe(undefined);
+ expect(fake.PROP_string).toBeUndefined();
// Added properties to the fake object are not added to the real one.
fake.PROP_ADDED = 'new!';
expect(fake.PROP_ADDED).toBe('new!');
- expect(process.env.PROP_ADDED).toBe(undefined);
+ expect(process.env.PROP_ADDED).toBeUndefined();
// You can delete properties, but they are case sensitive!
fake.prop = 'foo';
@@ -77,7 +77,7 @@ it('checks that process.env works as expected on Linux platforms', () => {
delete fake.PROP;
expect(fake.prop).toBe('foo');
- expect(fake.PROP).toBe(undefined);
+ expect(fake.PROP).toBeUndefined();
});
it('checks that process.env works as expected in Windows platforms', () => {
diff --git a/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts b/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts
index 71ac408dec55..518c9927657e 100644
--- a/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts
+++ b/packages/jest-util/src/__tests__/deepCyclicCopy.test.ts
@@ -11,8 +11,8 @@ import deepCyclicCopy from '../deepCyclicCopy';
it('returns the same value for primitive or function values', () => {
const fn = () => {};
- expect(deepCyclicCopy(undefined)).toBe(undefined);
- expect(deepCyclicCopy(null)).toBe(null);
+ expect(deepCyclicCopy(undefined)).toBeUndefined();
+ expect(deepCyclicCopy(null)).toBeNull();
expect(deepCyclicCopy(true)).toBe(true);
expect(deepCyclicCopy(42)).toBe(42);
expect(Number.isNaN(deepCyclicCopy(NaN))).toBe(true);
diff --git a/packages/jest-worker/src/__tests__/Farm.test.js b/packages/jest-worker/src/__tests__/Farm.test.js
index b8aacfe0242b..dbab6ac1abc6 100644
--- a/packages/jest-worker/src/__tests__/Farm.test.js
+++ b/packages/jest-worker/src/__tests__/Farm.test.js
@@ -186,7 +186,7 @@ describe('Farm', () => {
workerReply(0, null, 34);
const result = await promise;
- expect(result).toEqual(34);
+ expect(result).toBe(34);
});
it('throws if the call failed', async () => {
@@ -203,7 +203,7 @@ describe('Farm', () => {
error = err;
}
- expect(error).not.toBe(null);
+ expect(error).not.toBeNull();
expect(error).toBeInstanceOf(TypeError);
});
diff --git a/packages/jest-worker/src/__tests__/index.test.js b/packages/jest-worker/src/__tests__/index.test.js
index 92f6af320635..a01163a49121 100644
--- a/packages/jest-worker/src/__tests__/index.test.js
+++ b/packages/jest-worker/src/__tests__/index.test.js
@@ -165,7 +165,7 @@ it('calls doWork', async () => {
const promise = farm.foo('car', 'plane');
- expect(await promise).toEqual(42);
+ expect(await promise).toBe(42);
});
it('calls getStderr and getStdout from worker', async () => {
@@ -174,6 +174,6 @@ it('calls getStderr and getStdout from worker', async () => {
numWorkers: 1,
});
- expect(farm.getStderr()('err')).toEqual('err');
- expect(farm.getStdout()('out')).toEqual('out');
+ expect(farm.getStderr()('err')).toBe('err');
+ expect(farm.getStdout()('out')).toBe('out');
});
diff --git a/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js b/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js
index e13dfffcc141..5889dba13ad2 100644
--- a/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js
+++ b/packages/jest-worker/src/base/__tests__/BaseWorkerPool.test.js
@@ -112,9 +112,9 @@ describe('BaseWorkerPool', () => {
});
expect(Worker).toHaveBeenCalledTimes(3);
- expect(Worker.mock.calls[0][0].workerId).toEqual(0);
- expect(Worker.mock.calls[1][0].workerId).toEqual(1);
- expect(Worker.mock.calls[2][0].workerId).toEqual(2);
+ expect(Worker.mock.calls[0][0].workerId).toBe(0);
+ expect(Worker.mock.calls[1][0].workerId).toBe(1);
+ expect(Worker.mock.calls[2][0].workerId).toBe(2);
});
it('aggregates all stdouts and stderrs from all workers', () => {
diff --git a/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js b/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js
index bce2d97a3bea..1464a38cdaf4 100644
--- a/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js
+++ b/packages/jest-worker/src/workers/__tests__/ChildProcessWorker.test.js
@@ -97,7 +97,7 @@ it('passes workerId to the child process and assign it to 1-indexed env.JEST_WOR
workerPath: '/tmp/foo',
});
- expect(childProcess.fork.mock.calls[0][2].env.JEST_WORKER_ID).toEqual('3');
+ expect(childProcess.fork.mock.calls[0][2].env.JEST_WORKER_ID).toBe('3');
});
it('initializes the child process with the given workerPath', () => {
@@ -141,7 +141,7 @@ it('stops initializing the worker after the amount of retries is exceeded', () =
expect(onProcessEnd).toHaveBeenCalledTimes(1);
expect(onProcessEnd.mock.calls[0][0]).toBeInstanceOf(Error);
expect(onProcessEnd.mock.calls[0][0].type).toBe('WorkerError');
- expect(onProcessEnd.mock.calls[0][1]).toBe(null);
+ expect(onProcessEnd.mock.calls[0][1]).toBeNull();
});
it('provides stdout and stderr from the child processes', async () => {
@@ -161,8 +161,8 @@ it('provides stdout and stderr from the child processes', async () => {
forkInterface.stderr.end('Workers!', 'utf8');
forkInterface.emit('exit', 0);
- await expect(getStream(stdout)).resolves.toEqual('Hello World!');
- await expect(getStream(stderr)).resolves.toEqual('Jest Workers!');
+ await expect(getStream(stdout)).resolves.toBe('Hello World!');
+ await expect(getStream(stderr)).resolves.toBe('Jest Workers!');
});
it('sends the task to the child process', () => {
diff --git a/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js b/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js
index e522f44ffff6..98278c25ecee 100644
--- a/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js
+++ b/packages/jest-worker/src/workers/__tests__/NodeThreadsWorker.test.js
@@ -125,7 +125,7 @@ it('stops initializing the worker after the amount of retries is exceeded', () =
expect(onProcessEnd).toHaveBeenCalledTimes(1);
expect(onProcessEnd.mock.calls[0][0]).toBeInstanceOf(Error);
expect(onProcessEnd.mock.calls[0][0].type).toBe('WorkerError');
- expect(onProcessEnd.mock.calls[0][1]).toBe(null);
+ expect(onProcessEnd.mock.calls[0][1]).toBeNull();
});
it('provides stdout and stderr from the threads', async () => {
@@ -145,8 +145,8 @@ it('provides stdout and stderr from the threads', async () => {
worker._worker.stderr.end('Workers!', 'utf8');
worker._worker.emit('exit', 0);
- await expect(getStream(stdout)).resolves.toEqual('Hello World!');
- await expect(getStream(stderr)).resolves.toEqual('Jest Workers!');
+ await expect(getStream(stdout)).resolves.toBe('Hello World!');
+ await expect(getStream(stderr)).resolves.toBe('Jest Workers!');
});
it('sends the task to the thread', () => {
diff --git a/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.js b/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.js
index 0b68ea8755a6..cb87382792a4 100644
--- a/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.js
+++ b/packages/jest-worker/src/workers/__tests__/WorkerEdgeCases.test.js
@@ -376,7 +376,7 @@ describe.each([
// Give it some time to restart some workers
await new Promise(resolve => setTimeout(resolve, 4000));
- expect(startedWorkers).toEqual(6);
+ expect(startedWorkers).toBe(6);
expect(worker.isWorkerRunning()).toBeTruthy();
expect(worker.state).toEqual(WorkerStates.OK);
diff --git a/packages/jest-worker/src/workers/__tests__/processChild.test.js b/packages/jest-worker/src/workers/__tests__/processChild.test.js
index b1520765f1d5..b31b630f3962 100644
--- a/packages/jest-worker/src/workers/__tests__/processChild.test.js
+++ b/packages/jest-worker/src/workers/__tests__/processChild.test.js
@@ -140,7 +140,7 @@ it('lazily requires the file', () => {
]);
expect(mockCount).toBe(1);
- expect(initializeParm).toBe(undefined);
+ expect(initializeParm).toBeUndefined();
});
it('should return memory usage', () => {
@@ -248,9 +248,7 @@ it('returns results immediately when function is synchronous', () => {
expect(process.send.mock.calls[4][0][0]).toBe(PARENT_MESSAGE_CLIENT_ERROR);
expect(process.send.mock.calls[4][0][1]).toBe('Error');
- expect(process.send.mock.calls[4][0][2]).toEqual(
- '"null" or "undefined" thrown',
- );
+ expect(process.send.mock.calls[4][0][2]).toBe('"null" or "undefined" thrown');
expect(process.send).toHaveBeenCalledTimes(5);
});
diff --git a/packages/jest-worker/src/workers/__tests__/threadChild.test.js b/packages/jest-worker/src/workers/__tests__/threadChild.test.js
index fe0107a926f2..51d97a0fe867 100644
--- a/packages/jest-worker/src/workers/__tests__/threadChild.test.js
+++ b/packages/jest-worker/src/workers/__tests__/threadChild.test.js
@@ -160,7 +160,7 @@ it('lazily requires the file', () => {
]);
expect(mockCount).toBe(1);
- expect(initializeParm).toBe(undefined);
+ expect(initializeParm).toBeUndefined();
});
it('calls initialize with the correct arguments', () => {
@@ -260,7 +260,7 @@ it('returns results immediately when function is synchronous', () => {
PARENT_MESSAGE_CLIENT_ERROR,
);
expect(thread.postMessage.mock.calls[4][0][1]).toBe('Error');
- expect(thread.postMessage.mock.calls[4][0][2]).toEqual(
+ expect(thread.postMessage.mock.calls[4][0][2]).toBe(
'"null" or "undefined" thrown',
);
diff --git a/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts b/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts
index 95354dbeeadd..2a4af6a58542 100644
--- a/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts
+++ b/packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts
@@ -37,7 +37,7 @@ beforeEach(() => {
].forEach(type => {
test(`supports any(${fnNameFor(type)})`, () => {
const result = prettyFormat(expect.any(type), options);
- expect(result).toEqual(`Any<${fnNameFor(type)}>`);
+ expect(result).toBe(`Any<${fnNameFor(type)}>`);
});
test(`supports nested any(${fnNameFor(type)})`, () => {
@@ -49,7 +49,7 @@ beforeEach(() => {
},
options,
);
- expect(result).toEqual(
+ expect(result).toBe(
`Object {\n "test": Object {\n "nested": Any<${fnNameFor(
type,
)}>,\n },\n}`,
@@ -59,12 +59,12 @@ beforeEach(() => {
test('anything()', () => {
const result = prettyFormat(expect.anything(), options);
- expect(result).toEqual('Anything');
+ expect(result).toBe('Anything');
});
test('arrayContaining()', () => {
const result = prettyFormat(expect.arrayContaining([1, 2]), options);
- expect(result).toEqual(`ArrayContaining [
+ expect(result).toBe(`ArrayContaining [
1,
2,
]`);
@@ -72,7 +72,7 @@ test('arrayContaining()', () => {
test('arrayNotContaining()', () => {
const result = prettyFormat(expect.not.arrayContaining([1, 2]), options);
- expect(result).toEqual(`ArrayNotContaining [
+ expect(result).toBe(`ArrayNotContaining [
1,
2,
]`);
@@ -80,7 +80,7 @@ test('arrayNotContaining()', () => {
test('objectContaining()', () => {
const result = prettyFormat(expect.objectContaining({a: 'test'}), options);
- expect(result).toEqual(`ObjectContaining {
+ expect(result).toBe(`ObjectContaining {
"a": "test",
}`);
});
@@ -90,75 +90,75 @@ test('objectNotContaining()', () => {
expect.not.objectContaining({a: 'test'}),
options,
);
- expect(result).toEqual(`ObjectNotContaining {
+ expect(result).toBe(`ObjectNotContaining {
"a": "test",
}`);
});
test('stringContaining(string)', () => {
const result = prettyFormat(expect.stringContaining('jest'), options);
- expect(result).toEqual('StringContaining "jest"');
+ expect(result).toBe('StringContaining "jest"');
});
test('not.stringContaining(string)', () => {
const result = prettyFormat(expect.not.stringContaining('jest'), options);
- expect(result).toEqual('StringNotContaining "jest"');
+ expect(result).toBe('StringNotContaining "jest"');
});
test('stringMatching(string)', () => {
const result = prettyFormat(expect.stringMatching('jest'), options);
- expect(result).toEqual('StringMatching /jest/');
+ expect(result).toBe('StringMatching /jest/');
});
test('stringMatching(regexp)', () => {
const result = prettyFormat(expect.stringMatching(/(jest|niema).*/), options);
- expect(result).toEqual('StringMatching /(jest|niema).*/');
+ expect(result).toBe('StringMatching /(jest|niema).*/');
});
test('stringMatching(regexp) {escapeRegex: false}', () => {
const result = prettyFormat(expect.stringMatching(/regexp\d/gi), options);
- expect(result).toEqual('StringMatching /regexp\\d/gi');
+ expect(result).toBe('StringMatching /regexp\\d/gi');
});
test('stringMatching(regexp) {escapeRegex: true}', () => {
options.escapeRegex = true;
const result = prettyFormat(expect.stringMatching(/regexp\d/gi), options);
- expect(result).toEqual('StringMatching /regexp\\\\d/gi');
+ expect(result).toBe('StringMatching /regexp\\\\d/gi');
});
test('stringNotMatching(string)', () => {
const result = prettyFormat(expect.not.stringMatching('jest'), options);
- expect(result).toEqual('StringNotMatching /jest/');
+ expect(result).toBe('StringNotMatching /jest/');
});
test('closeTo(number, precision)', () => {
const result = prettyFormat(expect.closeTo(1.2345, 4), options);
- expect(result).toEqual('NumberCloseTo 1.2345 (4 digits)');
+ expect(result).toBe('NumberCloseTo 1.2345 (4 digits)');
});
test('notCloseTo(number, precision)', () => {
const result = prettyFormat(expect.not.closeTo(1.2345, 1), options);
- expect(result).toEqual('NumberNotCloseTo 1.2345 (1 digit)');
+ expect(result).toBe('NumberNotCloseTo 1.2345 (1 digit)');
});
test('closeTo(number)', () => {
const result = prettyFormat(expect.closeTo(1.2345), options);
- expect(result).toEqual('NumberCloseTo 1.2345 (2 digits)');
+ expect(result).toBe('NumberCloseTo 1.2345 (2 digits)');
});
test('closeTo(Infinity)', () => {
const result = prettyFormat(expect.closeTo(-Infinity), options);
- expect(result).toEqual('NumberCloseTo -Infinity (2 digits)');
+ expect(result).toBe('NumberCloseTo -Infinity (2 digits)');
});
test('closeTo(scientific number)', () => {
const result = prettyFormat(expect.closeTo(1.56e-3, 4), options);
- expect(result).toEqual('NumberCloseTo 0.00156 (4 digits)');
+ expect(result).toBe('NumberCloseTo 0.00156 (4 digits)');
});
test('closeTo(very small scientific number)', () => {
const result = prettyFormat(expect.closeTo(1.56e-10, 4), options);
- expect(result).toEqual('NumberCloseTo 1.56e-10 (4 digits)');
+ expect(result).toBe('NumberCloseTo 1.56e-10 (4 digits)');
});
test('correctly handles inability to pretty-print matcher', () => {
@@ -183,7 +183,7 @@ test('supports multiple nested asymmetric matchers', () => {
},
options,
);
- expect(result).toEqual(`Object {
+ expect(result).toBe(`Object {
"test": Object {
"nested": ObjectContaining {
"a": ArrayContaining [
@@ -278,7 +278,7 @@ describe('maxDepth option', () => {
],
};
const result = prettyFormat(val, options);
- expect(result).toEqual(`Object {
+ expect(result).toBe(`Object {
"nested": Array [
[ArrayContaining],
[ObjectContaining],
@@ -313,7 +313,7 @@ describe('maxDepth option', () => {
}),
];
const result = prettyFormat(val, options);
- expect(result).toEqual(`Array [
+ expect(result).toBe(`Array [
ArrayContaining [
"printed",
[Object],
@@ -343,7 +343,7 @@ test('min option', () => {
},
options,
);
- expect(result).toEqual(
+ expect(result).toBe(
'{"test": {"nested": ObjectContaining {"a": ArrayContaining [1], "b": Anything, "c": Any, "d": StringContaining "jest", "e": StringMatching /jest/, "f": ObjectContaining {"test": "case"}}}}',
);
});
diff --git a/packages/pretty-format/src/__tests__/DOMElement.test.ts b/packages/pretty-format/src/__tests__/DOMElement.test.ts
index c8e14e83dfa5..39e1dee998c8 100644
--- a/packages/pretty-format/src/__tests__/DOMElement.test.ts
+++ b/packages/pretty-format/src/__tests__/DOMElement.test.ts
@@ -21,7 +21,7 @@ setPrettyPrint([DOMElement]);
describe('pretty-format', () => {
// Test is not related to plugin but is related to jsdom testing environment.
it('prints global window as constructor name alone', () => {
- expect(prettyFormat(window)).toEqual('[Window]');
+ expect(prettyFormat(window)).toBe('[Window]');
});
});
diff --git a/packages/pretty-format/src/__tests__/prettyFormat.test.ts b/packages/pretty-format/src/__tests__/prettyFormat.test.ts
index 0d2662ef93ba..75afa767a4c9 100644
--- a/packages/pretty-format/src/__tests__/prettyFormat.test.ts
+++ b/packages/pretty-format/src/__tests__/prettyFormat.test.ts
@@ -23,90 +23,90 @@ function MyObject(value: unknown) {
describe('prettyFormat()', () => {
it('prints empty arguments', () => {
const val = returnArguments();
- expect(prettyFormat(val)).toEqual('Arguments []');
+ expect(prettyFormat(val)).toBe('Arguments []');
});
it('prints arguments', () => {
const val = returnArguments(1, 2, 3);
- expect(prettyFormat(val)).toEqual('Arguments [\n 1,\n 2,\n 3,\n]');
+ expect(prettyFormat(val)).toBe('Arguments [\n 1,\n 2,\n 3,\n]');
});
it('prints an empty array', () => {
const val: Array = [];
- expect(prettyFormat(val)).toEqual('Array []');
+ expect(prettyFormat(val)).toBe('Array []');
});
it('prints an array with items', () => {
const val = [1, 2, 3];
- expect(prettyFormat(val)).toEqual('Array [\n 1,\n 2,\n 3,\n]');
+ expect(prettyFormat(val)).toBe('Array [\n 1,\n 2,\n 3,\n]');
});
it('prints a sparse array with only holes', () => {
// eslint-disable-next-line no-sparse-arrays
const val = [, , ,];
- expect(prettyFormat(val)).toEqual('Array [\n ,\n ,\n ,\n]');
+ expect(prettyFormat(val)).toBe('Array [\n ,\n ,\n ,\n]');
});
it('prints a sparse array with items', () => {
// eslint-disable-next-line no-sparse-arrays
const val = [1, , , 4];
- expect(prettyFormat(val)).toEqual('Array [\n 1,\n ,\n ,\n 4,\n]');
+ expect(prettyFormat(val)).toBe('Array [\n 1,\n ,\n ,\n 4,\n]');
});
it('prints a sparse array with value surrounded by holes', () => {
// eslint-disable-next-line no-sparse-arrays
const val = [, 5, ,];
- expect(prettyFormat(val)).toEqual('Array [\n ,\n 5,\n ,\n]');
+ expect(prettyFormat(val)).toBe('Array [\n ,\n 5,\n ,\n]');
});
it('prints a sparse array also containing undefined values', () => {
// eslint-disable-next-line no-sparse-arrays
const val = [1, , undefined, undefined, , 4];
- expect(prettyFormat(val)).toEqual(
+ expect(prettyFormat(val)).toBe(
'Array [\n 1,\n ,\n undefined,\n undefined,\n ,\n 4,\n]',
);
});
it('prints a empty typed array', () => {
const val = new Uint32Array(0);
- expect(prettyFormat(val)).toEqual('Uint32Array []');
+ expect(prettyFormat(val)).toBe('Uint32Array []');
});
it('prints a typed array with items', () => {
const val = new Uint32Array(3);
- expect(prettyFormat(val)).toEqual('Uint32Array [\n 0,\n 0,\n 0,\n]');
+ expect(prettyFormat(val)).toBe('Uint32Array [\n 0,\n 0,\n 0,\n]');
});
it('prints an array buffer', () => {
const val = new ArrayBuffer(3);
- expect(prettyFormat(val)).toEqual('ArrayBuffer []');
+ expect(prettyFormat(val)).toBe('ArrayBuffer []');
});
it('prints a nested array', () => {
const val = [[1, 2, 3]];
- expect(prettyFormat(val)).toEqual(
+ expect(prettyFormat(val)).toBe(
'Array [\n Array [\n 1,\n 2,\n 3,\n ],\n]',
);
});
it('prints true', () => {
const val = true;
- expect(prettyFormat(val)).toEqual('true');
+ expect(prettyFormat(val)).toBe('true');
});
it('prints false', () => {
const val = false;
- expect(prettyFormat(val)).toEqual('false');
+ expect(prettyFormat(val)).toBe('false');
});
it('prints an error', () => {
const val = new Error();
- expect(prettyFormat(val)).toEqual('[Error]');
+ expect(prettyFormat(val)).toBe('[Error]');
});
it('prints a typed error with a message', () => {
const val = new TypeError('message');
- expect(prettyFormat(val)).toEqual('[TypeError: message]');
+ expect(prettyFormat(val)).toBe('[TypeError: message]');
});
it('prints a function constructor', () => {
@@ -114,7 +114,7 @@ describe('prettyFormat()', () => {
const val = new Function();
/* eslint-enable no-new-func */
// In Node >=8.1.4: val.name === 'anonymous'
- expect(prettyFormat(val)).toEqual('[Function anonymous]');
+ expect(prettyFormat(val)).toBe('[Function anonymous]');
});
it('prints an anonymous callback function', () => {
@@ -124,7 +124,7 @@ describe('prettyFormat()', () => {
}
f(() => {});
// In Node >=8.1.4: val.name === ''
- expect(prettyFormat(val)).toEqual('[Function anonymous]');
+ expect(prettyFormat(val)).toBe('[Function anonymous]');
});
it('prints an anonymous assigned function', () => {
@@ -138,7 +138,7 @@ describe('prettyFormat()', () => {
it('prints a named function', () => {
const val = function named() {};
- expect(prettyFormat(val)).toEqual('[Function named]');
+ expect(prettyFormat(val)).toBe('[Function named]');
});
it('prints a named generator function', () => {
@@ -147,7 +147,7 @@ describe('prettyFormat()', () => {
yield 2;
yield 3;
};
- expect(prettyFormat(val)).toEqual('[Function generate]');
+ expect(prettyFormat(val)).toBe('[Function generate]');
});
it('can customize function names', () => {
@@ -156,29 +156,29 @@ describe('prettyFormat()', () => {
prettyFormat(val, {
printFunctionName: false,
}),
- ).toEqual('[Function]');
+ ).toBe('[Function]');
});
it('prints Infinity', () => {
const val = Infinity;
- expect(prettyFormat(val)).toEqual('Infinity');
+ expect(prettyFormat(val)).toBe('Infinity');
});
it('prints -Infinity', () => {
const val = -Infinity;
- expect(prettyFormat(val)).toEqual('-Infinity');
+ expect(prettyFormat(val)).toBe('-Infinity');
});
it('prints an empty map', () => {
const val = new Map();
- expect(prettyFormat(val)).toEqual('Map {}');
+ expect(prettyFormat(val)).toBe('Map {}');
});
it('prints a map with values', () => {
const val = new Map();
val.set('prop1', 'value1');
val.set('prop2', 'value2');
- expect(prettyFormat(val)).toEqual(
+ expect(prettyFormat(val)).toBe(
'Map {\n "prop1" => "value1",\n "prop2" => "value2",\n}',
);
});
@@ -224,72 +224,72 @@ describe('prettyFormat()', () => {
it('prints NaN', () => {
const val = NaN;
- expect(prettyFormat(val)).toEqual('NaN');
+ expect(prettyFormat(val)).toBe('NaN');
});
it('prints null', () => {
const val = null;
- expect(prettyFormat(val)).toEqual('null');
+ expect(prettyFormat(val)).toBe('null');
});
it('prints a positive number', () => {
const val = 123;
- expect(prettyFormat(val)).toEqual('123');
+ expect(prettyFormat(val)).toBe('123');
});
it('prints a negative number', () => {
const val = -123;
- expect(prettyFormat(val)).toEqual('-123');
+ expect(prettyFormat(val)).toBe('-123');
});
it('prints zero', () => {
const val = 0;
- expect(prettyFormat(val)).toEqual('0');
+ expect(prettyFormat(val)).toBe('0');
});
it('prints negative zero', () => {
const val = -0;
- expect(prettyFormat(val)).toEqual('-0');
+ expect(prettyFormat(val)).toBe('-0');
});
it('prints a positive bigint', () => {
const val = BigInt(123);
- expect(prettyFormat(val)).toEqual('123n');
+ expect(prettyFormat(val)).toBe('123n');
});
it('prints a negative bigint', () => {
const val = BigInt(-123);
- expect(prettyFormat(val)).toEqual('-123n');
+ expect(prettyFormat(val)).toBe('-123n');
});
it('prints zero bigint', () => {
const val = BigInt(0);
- expect(prettyFormat(val)).toEqual('0n');
+ expect(prettyFormat(val)).toBe('0n');
});
it('prints negative zero bigint', () => {
const val = BigInt(-0);
- expect(prettyFormat(val)).toEqual('0n');
+ expect(prettyFormat(val)).toBe('0n');
});
it('prints a date', () => {
const val = new Date(10e11);
- expect(prettyFormat(val)).toEqual('2001-09-09T01:46:40.000Z');
+ expect(prettyFormat(val)).toBe('2001-09-09T01:46:40.000Z');
});
it('prints an invalid date', () => {
const val = new Date(Infinity);
- expect(prettyFormat(val)).toEqual('Date { NaN }');
+ expect(prettyFormat(val)).toBe('Date { NaN }');
});
it('prints an empty object', () => {
const val = {};
- expect(prettyFormat(val)).toEqual('Object {}');
+ expect(prettyFormat(val)).toBe('Object {}');
});
it('prints an object with properties', () => {
const val = {prop1: 'value1', prop2: 'value2'};
- expect(prettyFormat(val)).toEqual(
+ expect(prettyFormat(val)).toBe(
'Object {\n "prop1": "value1",\n "prop2": "value2",\n}',
);
});
@@ -299,7 +299,7 @@ describe('prettyFormat()', () => {
val[Symbol('symbol1')] = 'value2';
val[Symbol('symbol2')] = 'value3';
val.prop = 'value1';
- expect(prettyFormat(val)).toEqual(
+ expect(prettyFormat(val)).toBe(
'Object {\n "prop": "value1",\n Symbol(symbol1): "value2",\n Symbol(symbol2): "value3",\n}',
);
});
@@ -313,7 +313,7 @@ describe('prettyFormat()', () => {
enumerable: false,
value: false,
});
- expect(prettyFormat(val)).toEqual('Object {\n "enumerable": true,\n}');
+ expect(prettyFormat(val)).toBe('Object {\n "enumerable": true,\n}');
});
it('prints an object without non-enumerable properties which have symbol key', () => {
@@ -325,20 +325,20 @@ describe('prettyFormat()', () => {
enumerable: false,
value: false,
});
- expect(prettyFormat(val)).toEqual('Object {\n "enumerable": true,\n}');
+ expect(prettyFormat(val)).toBe('Object {\n "enumerable": true,\n}');
});
it('prints an object with sorted properties', () => {
// eslint-disable-next-line sort-keys
const val = {b: 1, a: 2};
- expect(prettyFormat(val)).toEqual('Object {\n "a": 2,\n "b": 1,\n}');
+ expect(prettyFormat(val)).toBe('Object {\n "a": 2,\n "b": 1,\n}');
});
it('prints an object with keys in their original order with the appropriate comparing function', () => {
// eslint-disable-next-line sort-keys
const val = {b: 1, a: 2};
const compareKeys = () => 0;
- expect(prettyFormat(val, {compareKeys})).toEqual(
+ expect(prettyFormat(val, {compareKeys})).toBe(
'Object {\n "b": 1,\n "a": 2,\n}',
);
});
@@ -346,7 +346,7 @@ describe('prettyFormat()', () => {
it('prints an object with keys in their original order with compareKeys set to null', () => {
// eslint-disable-next-line sort-keys
const val = {b: 1, a: 2};
- expect(prettyFormat(val, {compareKeys: null})).toEqual(
+ expect(prettyFormat(val, {compareKeys: null})).toBe(
'Object {\n "b": 1,\n "a": 2,\n}',
);
});
@@ -354,73 +354,73 @@ describe('prettyFormat()', () => {
it('prints an object with keys sorted in reverse order', () => {
const val = {a: 1, b: 2};
const compareKeys = (a: string, b: string) => (a > b ? -1 : 1);
- expect(prettyFormat(val, {compareKeys})).toEqual(
+ expect(prettyFormat(val, {compareKeys})).toBe(
'Object {\n "b": 2,\n "a": 1,\n}',
);
});
it('prints regular expressions from constructors', () => {
const val = new RegExp('regexp');
- expect(prettyFormat(val)).toEqual('/regexp/');
+ expect(prettyFormat(val)).toBe('/regexp/');
});
it('prints regular expressions from literals', () => {
const val = /regexp/gi;
- expect(prettyFormat(val)).toEqual('/regexp/gi');
+ expect(prettyFormat(val)).toBe('/regexp/gi');
});
it('prints regular expressions {escapeRegex: false}', () => {
const val = /regexp\d/gi;
- expect(prettyFormat(val)).toEqual('/regexp\\d/gi');
+ expect(prettyFormat(val)).toBe('/regexp\\d/gi');
});
it('prints regular expressions {escapeRegex: true}', () => {
const val = /regexp\d/gi;
- expect(prettyFormat(val, {escapeRegex: true})).toEqual('/regexp\\\\d/gi');
+ expect(prettyFormat(val, {escapeRegex: true})).toBe('/regexp\\\\d/gi');
});
it('escapes regular expressions nested inside object', () => {
const obj = {test: /regexp\d/gi};
- expect(prettyFormat(obj, {escapeRegex: true})).toEqual(
+ expect(prettyFormat(obj, {escapeRegex: true})).toBe(
'Object {\n "test": /regexp\\\\d/gi,\n}',
);
});
it('prints an empty set', () => {
const val = new Set();
- expect(prettyFormat(val)).toEqual('Set {}');
+ expect(prettyFormat(val)).toBe('Set {}');
});
it('prints a set with values', () => {
const val = new Set();
val.add('value1');
val.add('value2');
- expect(prettyFormat(val)).toEqual('Set {\n "value1",\n "value2",\n}');
+ expect(prettyFormat(val)).toBe('Set {\n "value1",\n "value2",\n}');
});
it('prints a string', () => {
const val = 'string';
- expect(prettyFormat(val)).toEqual('"string"');
+ expect(prettyFormat(val)).toBe('"string"');
});
it('prints and escape a string', () => {
const val = '"\'\\';
- expect(prettyFormat(val)).toEqual('"\\"\'\\\\"');
+ expect(prettyFormat(val)).toBe('"\\"\'\\\\"');
});
it("doesn't escape string with {escapeString: false}", () => {
const val = '"\'\\n';
- expect(prettyFormat(val, {escapeString: false})).toEqual('""\'\\n"');
+ expect(prettyFormat(val, {escapeString: false})).toBe('""\'\\n"');
});
it('prints a string with escapes', () => {
- expect(prettyFormat('"-"')).toEqual('"\\"-\\""');
- expect(prettyFormat('\\ \\\\')).toEqual('"\\\\ \\\\\\\\"');
+ expect(prettyFormat('"-"')).toBe('"\\"-\\""');
+ expect(prettyFormat('\\ \\\\')).toBe('"\\\\ \\\\\\\\"');
});
it('prints a multiline string', () => {
const val = ['line 1', 'line 2', 'line 3'].join('\n');
- expect(prettyFormat(val)).toEqual(`"${val}"`);
+ expect(prettyFormat(val)).toBe(`"${val}"`);
});
it('prints a multiline string as value of object property', () => {
@@ -459,27 +459,27 @@ describe('prettyFormat()', () => {
it('prints a symbol', () => {
const val = Symbol('symbol');
- expect(prettyFormat(val)).toEqual('Symbol(symbol)');
+ expect(prettyFormat(val)).toBe('Symbol(symbol)');
});
it('prints undefined', () => {
const val = undefined;
- expect(prettyFormat(val)).toEqual('undefined');
+ expect(prettyFormat(val)).toBe('undefined');
});
it('prints a WeakMap', () => {
const val = new WeakMap();
- expect(prettyFormat(val)).toEqual('WeakMap {}');
+ expect(prettyFormat(val)).toBe('WeakMap {}');
});
it('prints a WeakSet', () => {
const val = new WeakSet();
- expect(prettyFormat(val)).toEqual('WeakSet {}');
+ expect(prettyFormat(val)).toBe('WeakSet {}');
});
it('prints deeply nested objects', () => {
const val = {prop: {prop: {prop: 'value'}}};
- expect(prettyFormat(val)).toEqual(
+ expect(prettyFormat(val)).toBe(
'Object {\n "prop": Object {\n "prop": Object {\n "prop": "value",\n },\n },\n}',
);
});
@@ -487,13 +487,13 @@ describe('prettyFormat()', () => {
it('prints circular references', () => {
const val: any = {};
val.prop = val;
- expect(prettyFormat(val)).toEqual('Object {\n "prop": [Circular],\n}');
+ expect(prettyFormat(val)).toBe('Object {\n "prop": [Circular],\n}');
});
it('prints parallel references', () => {
const inner = {};
const val = {prop1: inner, prop2: inner};
- expect(prettyFormat(val)).toEqual(
+ expect(prettyFormat(val)).toBe(
'Object {\n "prop1": Object {},\n "prop2": Object {},\n}',
);
});
@@ -685,7 +685,7 @@ describe('prettyFormat()', () => {
},
],
}),
- ).toEqual('class Foo');
+ ).toBe('class Foo');
});
it('supports plugins that return empty string', () => {
@@ -704,7 +704,7 @@ describe('prettyFormat()', () => {
},
],
};
- expect(prettyFormat(val, options)).toEqual('');
+ expect(prettyFormat(val, options)).toBe('');
});
it('throws if plugin does not return a string', () => {
@@ -804,7 +804,7 @@ describe('prettyFormat()', () => {
},
],
}),
- ).toEqual('1 - 2 - 3 - 4');
+ ).toBe('1 - 2 - 3 - 4');
});
it('should call plugins on nested basic values', () => {
@@ -822,11 +822,11 @@ describe('prettyFormat()', () => {
},
],
}),
- ).toEqual('Object {\n [called]: [called],\n}');
+ ).toBe('Object {\n [called]: [called],\n}');
});
it('prints objects with no constructor', () => {
- expect(prettyFormat(Object.create(null))).toEqual('Object {}');
+ expect(prettyFormat(Object.create(null))).toBe('Object {}');
});
it('prints identity-obj-proxy with string constructor', () => {
@@ -846,7 +846,7 @@ describe('prettyFormat()', () => {
toJSON: () => ({value: false}),
value: true,
}),
- ).toEqual('Object {\n "value": false,\n}');
+ ).toBe('Object {\n "value": false,\n}');
});
it('calls toJSON and prints an internal representation.', () => {
@@ -855,7 +855,7 @@ describe('prettyFormat()', () => {
toJSON: () => '[Internal Object]',
value: true,
}),
- ).toEqual('"[Internal Object]"');
+ ).toBe('"[Internal Object]"');
});
it('calls toJSON only on functions', () => {
@@ -864,7 +864,7 @@ describe('prettyFormat()', () => {
toJSON: false,
value: true,
}),
- ).toEqual('Object {\n "toJSON": false,\n "value": true,\n}');
+ ).toBe('Object {\n "toJSON": false,\n "value": true,\n}');
});
it('does not call toJSON recursively', () => {
@@ -873,13 +873,13 @@ describe('prettyFormat()', () => {
toJSON: () => ({toJSON: () => ({value: true})}),
value: false,
}),
- ).toEqual('Object {\n "toJSON": [Function toJSON],\n}');
+ ).toBe('Object {\n "toJSON": [Function toJSON],\n}');
});
it('calls toJSON on Sets', () => {
const set = new Set([1]);
(set as any).toJSON = () => 'map';
- expect(prettyFormat(set)).toEqual('"map"');
+ expect(prettyFormat(set)).toBe('"map"');
});
it('disables toJSON calls through options', () => {
@@ -891,7 +891,7 @@ describe('prettyFormat()', () => {
prettyFormat(set, {
callToJSON: false,
}),
- ).toEqual(
+ ).toBe(
`Set {\n Object {\n "apple": "banana",\n "toJSON": [Function ${name}],\n },\n}`,
);
expect((set as any).toJSON).not.toBeCalled();
@@ -911,7 +911,7 @@ describe('prettyFormat()', () => {
prettyFormat(val, {
min: true,
}),
- ).toEqual(
+ ).toBe(
`{${[
'"boolean": [false, true]',
'"null": null',
@@ -943,7 +943,7 @@ describe('prettyFormat()', () => {
prettyFormat(val, {
min: true,
}),
- ).toEqual(
+ ).toBe(
`{${[
'"arguments empty": []',
'"arguments non-empty": ["arg"]',
diff --git a/packages/pretty-format/src/__tests__/react.test.tsx b/packages/pretty-format/src/__tests__/react.test.tsx
index 5e8ba13f9c87..d555fe01f005 100644
--- a/packages/pretty-format/src/__tests__/react.test.tsx
+++ b/packages/pretty-format/src/__tests__/react.test.tsx
@@ -277,7 +277,7 @@ test('supports a single element with custom React elements with a child', () =>
});
test('supports undefined element type', () => {
- expect(formatElement({$$typeof: elementSymbol, props: {}})).toEqual(
+ expect(formatElement({$$typeof: elementSymbol, props: {}})).toBe(
'',
);
});
@@ -285,7 +285,7 @@ test('supports undefined element type', () => {
test('supports a fragment with no children', () => {
expect(
formatElement({$$typeof: elementSymbol, props: {}, type: fragmentSymbol}),
- ).toEqual('');
+ ).toBe('');
});
test('supports a fragment with string child', () => {
@@ -295,7 +295,7 @@ test('supports a fragment with string child', () => {
props: {children: 'test'},
type: fragmentSymbol,
}),
- ).toEqual('\n test\n');
+ ).toBe('\n test\n');
});
test('supports a fragment with element child', () => {
@@ -305,7 +305,7 @@ test('supports a fragment with element child', () => {
props: {children: React.createElement('div', null, 'test')},
type: fragmentSymbol,
}),
- ).toEqual('\n \n test\n
\n');
+ ).toBe('\n \n test\n
\n');
});
test('supports suspense', () => {
@@ -317,7 +317,7 @@ test('supports suspense', () => {
},
type: suspenseSymbol,
}),
- ).toEqual('\n \n test\n
\n');
+ ).toBe('\n \n test\n
\n');
});
test('supports a single element with React elements with a child', () => {
@@ -399,7 +399,7 @@ describe('test object for subset match', () => {
children: ['undefined props'],
type: 'span',
};
- expect(formatTestObject(val)).toEqual('\n undefined props\n');
+ expect(formatTestObject(val)).toBe('\n undefined props\n');
});
test('undefined children', () => {
const val = {
@@ -409,7 +409,7 @@ describe('test object for subset match', () => {
},
type: 'span',
};
- expect(formatTestObject(val)).toEqual(
+ expect(formatTestObject(val)).toBe(
'',
);
});
@@ -712,7 +712,7 @@ test('supports forwardRef with a child', () => {
expect(
formatElement(React.createElement(React.forwardRef(Cat), null, 'mouse')),
- ).toEqual('\n mouse\n');
+ ).toBe('\n mouse\n');
});
describe('React.memo', () => {
@@ -724,7 +724,7 @@ describe('React.memo', () => {
expect(
formatElement(React.createElement(React.memo(Dog), null, 'cat')),
- ).toEqual('\n cat\n');
+ ).toBe('\n cat\n');
});
});
@@ -734,7 +734,7 @@ describe('React.memo', () => {
Foo.displayName = 'DisplayNameBeforeMemoizing(Foo)';
const MemoFoo = React.memo(Foo);
- expect(formatElement(React.createElement(MemoFoo, null, 'cat'))).toEqual(
+ expect(formatElement(React.createElement(MemoFoo, null, 'cat'))).toBe(
'\n cat\n',
);
});
@@ -745,7 +745,7 @@ describe('React.memo', () => {
const MemoFoo = React.memo(Foo);
MemoFoo.displayName = 'DisplayNameForMemoized(Foo)';
- expect(formatElement(React.createElement(MemoFoo, null, 'cat'))).toEqual(
+ expect(formatElement(React.createElement(MemoFoo, null, 'cat'))).toBe(
'\n cat\n',
);
});
@@ -759,7 +759,7 @@ test('supports context Provider with a child', () => {
formatElement(
React.createElement(Provider, {value: 'test-value'}, 'child'),
),
- ).toEqual(
+ ).toBe(
'\n child\n',
);
});
@@ -773,7 +773,7 @@ test('supports context Consumer with a child', () => {
React.createElement('div', null, 'child'),
),
),
- ).toEqual('\n [Function anonymous]\n');
+ ).toBe('\n [Function anonymous]\n');
});
test('ReactElement removes undefined props', () => {
diff --git a/website/blog/2016-03-11-javascript-unit-testing-performance.md b/website/blog/2016-03-11-javascript-unit-testing-performance.md
index b59de046ad25..706dc9a642c8 100644
--- a/website/blog/2016-03-11-javascript-unit-testing-performance.md
+++ b/website/blog/2016-03-11-javascript-unit-testing-performance.md
@@ -45,7 +45,7 @@ If you have written tests using Jasmine before, they probably look like this:
const sum = require('sum');
describe('sum', () => {
it('works', () => {
- expect(sum(5, 4)).toEqual(9);
+ expect(sum(5, 4)).toBe(9);
});
});
```
@@ -61,11 +61,11 @@ describe('sum', () => {
sum = require('sum');
});
it('works', () => {
- expect(sum(5, 4)).toEqual(9);
+ expect(sum(5, 4)).toBe(9);
});
it('works too', () => {
// This copy of sum is not the same as in the previous call to `it`.
- expect(sum(2, 3)).toEqual(5);
+ expect(sum(2, 3)).toBe(5);
});
});
```
@@ -75,7 +75,7 @@ We built a babel transform called [inline-requires](https://github.com/facebook/
```js
describe('sum', () => {
it('works', () => {
- expect(require('sum')(5, 4)).toEqual(9);
+ expect(require('sum')(5, 4)).toBe(9);
});
});
```
diff --git a/website/blog/2016-04-12-jest-11.md b/website/blog/2016-04-12-jest-11.md
index 2991188f481b..af68f07cbc87 100644
--- a/website/blog/2016-04-12-jest-11.md
+++ b/website/blog/2016-04-12-jest-11.md
@@ -53,7 +53,7 @@ We have made numerous improvements and bug fixes to Jest's automocking feature,
We have also added two new APIs to simplify manual mocks. `jest.mock` specifies a manual mock factory for a specific test:
-```
+```js
// Implement a mock for a hypothetical "sum" module.
jest.mock('sum', () => {
return (a, b) => a + b;
@@ -65,11 +65,11 @@ sum(1, 4); // 5
And `jest.fn` was added to make it easier to create mock functions:
-```
+```js
// Create a mock function
const mockFn = jest.fn(() => 42);
mockFn(); // 42
-expect(mockFn.calls.length).toEqual(1);
+expect(mockFn.calls.length).toBe(1);
```
#### Performance
diff --git a/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md b/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md
index 320a55dd8b55..a17f26439b59 100644
--- a/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md
+++ b/website/blog/2017-05-06-jest-20-delightful-testing-multi-project-runner.md
@@ -44,7 +44,7 @@ We made a number of additions and improvements to the testing APIs which will he
Here is an example of all how all the new APIs together will make testing more delightful:
-```
+```js
/**
* @jest-environment node
*/
diff --git a/website/versioned_docs/version-25.x/Es6ClassMocks.md b/website/versioned_docs/version-25.x/Es6ClassMocks.md
index bf81bec755ec..529f4014ea7a 100644
--- a/website/versioned_docs/version-25.x/Es6ClassMocks.md
+++ b/website/versioned_docs/version-25.x/Es6ClassMocks.md
@@ -81,7 +81,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// mock.instances is available with automatic mocks:
const mockSoundPlayerInstance = SoundPlayer.mock.instances[0];
const mockPlaySoundFile = mockSoundPlayerInstance.playSoundFile;
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
// Equivalent to above check:
expect(mockPlaySoundFile).toHaveBeenCalledWith(coolSoundFileName);
expect(mockPlaySoundFile).toHaveBeenCalledTimes(1);
@@ -349,7 +349,7 @@ jest.mock('./sound-player', () => {
});
```
-This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toEqual(1);`
+This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBe(1);`
### Mocking non-default class exports
@@ -444,6 +444,6 @@ it('We can check if the consumer called a method on the class instance', () => {
const soundPlayerConsumer = new SoundPlayerConsumer();
const coolSoundFileName = 'song.mp3';
soundPlayerConsumer.playSomethingCool();
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
});
```
diff --git a/website/versioned_docs/version-25.x/JestObjectAPI.md b/website/versioned_docs/version-25.x/JestObjectAPI.md
index 3361d313e0ec..b78e6ec24ac3 100644
--- a/website/versioned_docs/version-25.x/JestObjectAPI.md
+++ b/website/versioned_docs/version-25.x/JestObjectAPI.md
@@ -117,7 +117,7 @@ utils.isAuthorized = jest.fn(secret => secret === 'not wizard');
test('implementation created by jest.genMockFromModule', () => {
expect(utils.authorize.mock).toBeTruthy();
- expect(utils.isAuthorized('not wizard')).toEqual(true);
+ expect(utils.isAuthorized('not wizard')).toBe(true);
});
```
@@ -180,17 +180,17 @@ const example = jest.genMockFromModule('./example');
test('should run example code', () => {
// creates a new mocked function with no formal arguments.
- expect(example.function.name).toEqual('square');
- expect(example.function.length).toEqual(0);
+ expect(example.function.name).toBe('square');
+ expect(example.function.length).toBe(0);
// async functions get the same treatment as standard synchronous functions.
- expect(example.asyncFunction.name).toEqual('asyncSquare');
- expect(example.asyncFunction.length).toEqual(0);
+ expect(example.asyncFunction.name).toBe('asyncSquare');
+ expect(example.asyncFunction.length).toBe(0);
// creates a new class with the same interface, member functions and properties are mocked.
- expect(example.class.constructor.name).toEqual('Bar');
- expect(example.class.foo.name).toEqual('foo');
- expect(example.class.array.length).toEqual(0);
+ expect(example.class.constructor.name).toBe('Bar');
+ expect(example.class.foo.name).toBe('foo');
+ expect(example.class.array.length).toBe(0);
// creates a deeply cloned version of the original object.
expect(example.object).toEqual({
@@ -202,12 +202,12 @@ test('should run example code', () => {
});
// creates a new empty array, ignoring the original array.
- expect(example.array.length).toEqual(0);
+ expect(example.array.length).toBe(0);
// creates a new property with the same primitive value as the original property.
- expect(example.number).toEqual(123);
- expect(example.string).toEqual('baz');
- expect(example.boolean).toEqual(true);
+ expect(example.number).toBe(123);
+ expect(example.string).toBe('baz');
+ expect(example.boolean).toBe(true);
expect(example.symbol).toEqual(Symbol.for('a.b.c'));
});
```
@@ -302,7 +302,7 @@ test('moduleName 1', () => {
return jest.fn(() => 1);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(1);
+ expect(moduleName()).toBe(1);
});
test('moduleName 2', () => {
@@ -310,7 +310,7 @@ test('moduleName 2', () => {
return jest.fn(() => 2);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(2);
+ expect(moduleName()).toBe(2);
});
```
@@ -334,8 +334,8 @@ test('moduleName 1', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default1');
- expect(moduleName.foo).toEqual('foo1');
+ expect(moduleName.default).toBe('default1');
+ expect(moduleName.foo).toBe('foo1');
});
});
@@ -348,8 +348,8 @@ test('moduleName 2', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default2');
- expect(moduleName.foo).toEqual('foo2');
+ expect(moduleName.default).toBe('default2');
+ expect(moduleName.foo).toBe('foo2');
});
});
```
diff --git a/website/versioned_docs/version-25.x/MockFunctionAPI.md b/website/versioned_docs/version-25.x/MockFunctionAPI.md
index e886053bb885..8966e1d28856 100644
--- a/website/versioned_docs/version-25.x/MockFunctionAPI.md
+++ b/website/versioned_docs/version-25.x/MockFunctionAPI.md
@@ -437,7 +437,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// However, it will not allow access to `.mock` in TypeScript as it
// is returning `SoundPlayer`. Instead, you can check the calls to a
// method like this fully typed:
- expect(SoundPlayerMock.prototype.playSoundFile.mock.calls[0][0]).toEqual(
+ expect(SoundPlayerMock.prototype.playSoundFile.mock.calls[0][0]).toBe(
coolSoundFileName,
);
// Equivalent to above check:
diff --git a/website/versioned_docs/version-25.x/MockFunctions.md b/website/versioned_docs/version-25.x/MockFunctions.md
index d9bb85206fe0..918fc826a74b 100644
--- a/website/versioned_docs/version-25.x/MockFunctions.md
+++ b/website/versioned_docs/version-25.x/MockFunctions.md
@@ -74,7 +74,7 @@ expect(someMockFunction.mock.instances.length).toBe(2);
// The object returned by the first instantiation of this function
// had a `name` property whose value was set to 'test'
-expect(someMockFunction.mock.instances[0].name).toEqual('test');
+expect(someMockFunction.mock.instances[0].name).toBe('test');
```
## Mock Return Values
diff --git a/website/versioned_docs/version-25.x/SetupAndTeardown.md b/website/versioned_docs/version-25.x/SetupAndTeardown.md
index 131376d0de6f..8d7a77020178 100644
--- a/website/versioned_docs/version-25.x/SetupAndTeardown.md
+++ b/website/versioned_docs/version-25.x/SetupAndTeardown.md
@@ -141,7 +141,7 @@ describe('outer', () => {
console.log('describe inner 1');
test('test 1', () => {
console.log('test for describe inner 1');
- expect(true).toEqual(true);
+ expect(true).toBe(true);
});
});
@@ -149,14 +149,14 @@ describe('outer', () => {
test('test 1', () => {
console.log('test for describe outer');
- expect(true).toEqual(true);
+ expect(true).toBe(true);
});
describe('describe inner 2', () => {
console.log('describe inner 2');
test('test for describe inner 2', () => {
console.log('test for describe inner 2');
- expect(false).toEqual(false);
+ expect(false).toBe(false);
});
});
diff --git a/website/versioned_docs/version-25.x/TutorialAsync.md b/website/versioned_docs/version-25.x/TutorialAsync.md
index b2872a4947a7..f9bbe7f6713f 100644
--- a/website/versioned_docs/version-25.x/TutorialAsync.md
+++ b/website/versioned_docs/version-25.x/TutorialAsync.md
@@ -68,7 +68,7 @@ import * as user from '../user';
// The assertion for a promise must be returned.
it('works with promises', () => {
expect.assertions(1);
- return user.getUserName(4).then(data => expect(data).toEqual('Mark'));
+ return user.getUserName(4).then(data => expect(data).toBe('Mark'));
});
```
@@ -81,7 +81,7 @@ There is a less verbose way using `resolves` to unwrap the value of a fulfilled
```js
it('works with resolves', () => {
expect.assertions(1);
- return expect(user.getUserName(5)).resolves.toEqual('Paul');
+ return expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
@@ -94,13 +94,13 @@ Writing tests using the `async`/`await` syntax is also possible. Here is how you
it('works with async/await', async () => {
expect.assertions(1);
const data = await user.getUserName(4);
- expect(data).toEqual('Mark');
+ expect(data).toBe('Mark');
});
// async/await can also be used with `.resolves`.
it('works with async/await and resolves', async () => {
expect.assertions(1);
- await expect(user.getUserName(5)).resolves.toEqual('Paul');
+ await expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
diff --git a/website/versioned_docs/version-25.x/TutorialReact.md b/website/versioned_docs/version-25.x/TutorialReact.md
index 3fabcdd5cb4b..6d0517a30aa9 100644
--- a/website/versioned_docs/version-25.x/TutorialReact.md
+++ b/website/versioned_docs/version-25.x/TutorialReact.md
@@ -268,11 +268,11 @@ test('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkbox = shallow();
- expect(checkbox.text()).toEqual('Off');
+ expect(checkbox.text()).toBe('Off');
checkbox.find('input').simulate('change');
- expect(checkbox.text()).toEqual('On');
+ expect(checkbox.text()).toBe('On');
});
```
diff --git a/website/versioned_docs/version-25.x/TutorialjQuery.md b/website/versioned_docs/version-25.x/TutorialjQuery.md
index 13a309ec4763..d6f32d3c74f6 100644
--- a/website/versioned_docs/version-25.x/TutorialjQuery.md
+++ b/website/versioned_docs/version-25.x/TutorialjQuery.md
@@ -55,7 +55,7 @@ test('displays a user after a click', () => {
// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
- expect($('#username').text()).toEqual('Johnny Cash - Logged In');
+ expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
diff --git a/website/versioned_docs/version-26.x/Es6ClassMocks.md b/website/versioned_docs/version-26.x/Es6ClassMocks.md
index bf81bec755ec..529f4014ea7a 100644
--- a/website/versioned_docs/version-26.x/Es6ClassMocks.md
+++ b/website/versioned_docs/version-26.x/Es6ClassMocks.md
@@ -81,7 +81,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// mock.instances is available with automatic mocks:
const mockSoundPlayerInstance = SoundPlayer.mock.instances[0];
const mockPlaySoundFile = mockSoundPlayerInstance.playSoundFile;
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
// Equivalent to above check:
expect(mockPlaySoundFile).toHaveBeenCalledWith(coolSoundFileName);
expect(mockPlaySoundFile).toHaveBeenCalledTimes(1);
@@ -349,7 +349,7 @@ jest.mock('./sound-player', () => {
});
```
-This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toEqual(1);`
+This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBe(1);`
### Mocking non-default class exports
@@ -444,6 +444,6 @@ it('We can check if the consumer called a method on the class instance', () => {
const soundPlayerConsumer = new SoundPlayerConsumer();
const coolSoundFileName = 'song.mp3';
soundPlayerConsumer.playSomethingCool();
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
});
```
diff --git a/website/versioned_docs/version-26.x/JestObjectAPI.md b/website/versioned_docs/version-26.x/JestObjectAPI.md
index 873db7c1e98a..2fb4b280831f 100644
--- a/website/versioned_docs/version-26.x/JestObjectAPI.md
+++ b/website/versioned_docs/version-26.x/JestObjectAPI.md
@@ -121,7 +121,7 @@ utils.isAuthorized = jest.fn(secret => secret === 'not wizard');
test('implementation created by jest.createMockFromModule', () => {
expect(utils.authorize.mock).toBeTruthy();
- expect(utils.isAuthorized('not wizard')).toEqual(true);
+ expect(utils.isAuthorized('not wizard')).toBe(true);
});
```
@@ -184,17 +184,17 @@ const example = jest.createMockFromModule('./example');
test('should run example code', () => {
// creates a new mocked function with no formal arguments.
- expect(example.function.name).toEqual('square');
- expect(example.function.length).toEqual(0);
+ expect(example.function.name).toBe('square');
+ expect(example.function.length).toBe(0);
// async functions get the same treatment as standard synchronous functions.
- expect(example.asyncFunction.name).toEqual('asyncSquare');
- expect(example.asyncFunction.length).toEqual(0);
+ expect(example.asyncFunction.name).toBe('asyncSquare');
+ expect(example.asyncFunction.length).toBe(0);
// creates a new class with the same interface, member functions and properties are mocked.
- expect(example.class.constructor.name).toEqual('Bar');
- expect(example.class.foo.name).toEqual('foo');
- expect(example.class.array.length).toEqual(0);
+ expect(example.class.constructor.name).toBe('Bar');
+ expect(example.class.foo.name).toBe('foo');
+ expect(example.class.array.length).toBe(0);
// creates a deeply cloned version of the original object.
expect(example.object).toEqual({
@@ -206,12 +206,12 @@ test('should run example code', () => {
});
// creates a new empty array, ignoring the original array.
- expect(example.array.length).toEqual(0);
+ expect(example.array.length).toBe(0);
// creates a new property with the same primitive value as the original property.
- expect(example.number).toEqual(123);
- expect(example.string).toEqual('baz');
- expect(example.boolean).toEqual(true);
+ expect(example.number).toBe(123);
+ expect(example.string).toBe('baz');
+ expect(example.boolean).toBe(true);
expect(example.symbol).toEqual(Symbol.for('a.b.c'));
});
```
@@ -306,7 +306,7 @@ test('moduleName 1', () => {
return jest.fn(() => 1);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(1);
+ expect(moduleName()).toBe(1);
});
test('moduleName 2', () => {
@@ -314,7 +314,7 @@ test('moduleName 2', () => {
return jest.fn(() => 2);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(2);
+ expect(moduleName()).toBe(2);
});
```
@@ -338,8 +338,8 @@ test('moduleName 1', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default1');
- expect(moduleName.foo).toEqual('foo1');
+ expect(moduleName.default).toBe('default1');
+ expect(moduleName.foo).toBe('foo1');
});
});
@@ -352,8 +352,8 @@ test('moduleName 2', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default2');
- expect(moduleName.foo).toEqual('foo2');
+ expect(moduleName.default).toBe('default2');
+ expect(moduleName.foo).toBe('foo2');
});
});
```
diff --git a/website/versioned_docs/version-26.x/MockFunctionAPI.md b/website/versioned_docs/version-26.x/MockFunctionAPI.md
index e886053bb885..8966e1d28856 100644
--- a/website/versioned_docs/version-26.x/MockFunctionAPI.md
+++ b/website/versioned_docs/version-26.x/MockFunctionAPI.md
@@ -437,7 +437,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// However, it will not allow access to `.mock` in TypeScript as it
// is returning `SoundPlayer`. Instead, you can check the calls to a
// method like this fully typed:
- expect(SoundPlayerMock.prototype.playSoundFile.mock.calls[0][0]).toEqual(
+ expect(SoundPlayerMock.prototype.playSoundFile.mock.calls[0][0]).toBe(
coolSoundFileName,
);
// Equivalent to above check:
diff --git a/website/versioned_docs/version-26.x/MockFunctions.md b/website/versioned_docs/version-26.x/MockFunctions.md
index d9bb85206fe0..918fc826a74b 100644
--- a/website/versioned_docs/version-26.x/MockFunctions.md
+++ b/website/versioned_docs/version-26.x/MockFunctions.md
@@ -74,7 +74,7 @@ expect(someMockFunction.mock.instances.length).toBe(2);
// The object returned by the first instantiation of this function
// had a `name` property whose value was set to 'test'
-expect(someMockFunction.mock.instances[0].name).toEqual('test');
+expect(someMockFunction.mock.instances[0].name).toBe('test');
```
## Mock Return Values
diff --git a/website/versioned_docs/version-26.x/SetupAndTeardown.md b/website/versioned_docs/version-26.x/SetupAndTeardown.md
index 131376d0de6f..8d7a77020178 100644
--- a/website/versioned_docs/version-26.x/SetupAndTeardown.md
+++ b/website/versioned_docs/version-26.x/SetupAndTeardown.md
@@ -141,7 +141,7 @@ describe('outer', () => {
console.log('describe inner 1');
test('test 1', () => {
console.log('test for describe inner 1');
- expect(true).toEqual(true);
+ expect(true).toBe(true);
});
});
@@ -149,14 +149,14 @@ describe('outer', () => {
test('test 1', () => {
console.log('test for describe outer');
- expect(true).toEqual(true);
+ expect(true).toBe(true);
});
describe('describe inner 2', () => {
console.log('describe inner 2');
test('test for describe inner 2', () => {
console.log('test for describe inner 2');
- expect(false).toEqual(false);
+ expect(false).toBe(false);
});
});
diff --git a/website/versioned_docs/version-26.x/TutorialAsync.md b/website/versioned_docs/version-26.x/TutorialAsync.md
index b2872a4947a7..f9bbe7f6713f 100644
--- a/website/versioned_docs/version-26.x/TutorialAsync.md
+++ b/website/versioned_docs/version-26.x/TutorialAsync.md
@@ -68,7 +68,7 @@ import * as user from '../user';
// The assertion for a promise must be returned.
it('works with promises', () => {
expect.assertions(1);
- return user.getUserName(4).then(data => expect(data).toEqual('Mark'));
+ return user.getUserName(4).then(data => expect(data).toBe('Mark'));
});
```
@@ -81,7 +81,7 @@ There is a less verbose way using `resolves` to unwrap the value of a fulfilled
```js
it('works with resolves', () => {
expect.assertions(1);
- return expect(user.getUserName(5)).resolves.toEqual('Paul');
+ return expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
@@ -94,13 +94,13 @@ Writing tests using the `async`/`await` syntax is also possible. Here is how you
it('works with async/await', async () => {
expect.assertions(1);
const data = await user.getUserName(4);
- expect(data).toEqual('Mark');
+ expect(data).toBe('Mark');
});
// async/await can also be used with `.resolves`.
it('works with async/await and resolves', async () => {
expect.assertions(1);
- await expect(user.getUserName(5)).resolves.toEqual('Paul');
+ await expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
diff --git a/website/versioned_docs/version-26.x/TutorialReact.md b/website/versioned_docs/version-26.x/TutorialReact.md
index 3fabcdd5cb4b..6d0517a30aa9 100644
--- a/website/versioned_docs/version-26.x/TutorialReact.md
+++ b/website/versioned_docs/version-26.x/TutorialReact.md
@@ -268,11 +268,11 @@ test('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkbox = shallow();
- expect(checkbox.text()).toEqual('Off');
+ expect(checkbox.text()).toBe('Off');
checkbox.find('input').simulate('change');
- expect(checkbox.text()).toEqual('On');
+ expect(checkbox.text()).toBe('On');
});
```
diff --git a/website/versioned_docs/version-26.x/TutorialjQuery.md b/website/versioned_docs/version-26.x/TutorialjQuery.md
index 13a309ec4763..d6f32d3c74f6 100644
--- a/website/versioned_docs/version-26.x/TutorialjQuery.md
+++ b/website/versioned_docs/version-26.x/TutorialjQuery.md
@@ -55,7 +55,7 @@ test('displays a user after a click', () => {
// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
- expect($('#username').text()).toEqual('Johnny Cash - Logged In');
+ expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
diff --git a/website/versioned_docs/version-27.x/Es6ClassMocks.md b/website/versioned_docs/version-27.x/Es6ClassMocks.md
index bf81bec755ec..529f4014ea7a 100644
--- a/website/versioned_docs/version-27.x/Es6ClassMocks.md
+++ b/website/versioned_docs/version-27.x/Es6ClassMocks.md
@@ -81,7 +81,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// mock.instances is available with automatic mocks:
const mockSoundPlayerInstance = SoundPlayer.mock.instances[0];
const mockPlaySoundFile = mockSoundPlayerInstance.playSoundFile;
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
// Equivalent to above check:
expect(mockPlaySoundFile).toHaveBeenCalledWith(coolSoundFileName);
expect(mockPlaySoundFile).toHaveBeenCalledTimes(1);
@@ -349,7 +349,7 @@ jest.mock('./sound-player', () => {
});
```
-This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toEqual(1);`
+This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBe(1);`
### Mocking non-default class exports
@@ -444,6 +444,6 @@ it('We can check if the consumer called a method on the class instance', () => {
const soundPlayerConsumer = new SoundPlayerConsumer();
const coolSoundFileName = 'song.mp3';
soundPlayerConsumer.playSomethingCool();
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
});
```
diff --git a/website/versioned_docs/version-27.x/JestObjectAPI.md b/website/versioned_docs/version-27.x/JestObjectAPI.md
index 782d1c9e28b7..0346af981e65 100644
--- a/website/versioned_docs/version-27.x/JestObjectAPI.md
+++ b/website/versioned_docs/version-27.x/JestObjectAPI.md
@@ -121,7 +121,7 @@ utils.isAuthorized = jest.fn(secret => secret === 'not wizard');
test('implementation created by jest.createMockFromModule', () => {
expect(utils.authorize.mock).toBeTruthy();
- expect(utils.isAuthorized('not wizard')).toEqual(true);
+ expect(utils.isAuthorized('not wizard')).toBe(true);
});
```
@@ -184,17 +184,17 @@ const example = jest.createMockFromModule('./example');
test('should run example code', () => {
// creates a new mocked function with no formal arguments.
- expect(example.function.name).toEqual('square');
- expect(example.function.length).toEqual(0);
+ expect(example.function.name).toBe('square');
+ expect(example.function.length).toBe(0);
// async functions get the same treatment as standard synchronous functions.
- expect(example.asyncFunction.name).toEqual('asyncSquare');
- expect(example.asyncFunction.length).toEqual(0);
+ expect(example.asyncFunction.name).toBe('asyncSquare');
+ expect(example.asyncFunction.length).toBe(0);
// creates a new class with the same interface, member functions and properties are mocked.
- expect(example.class.constructor.name).toEqual('Bar');
- expect(example.class.foo.name).toEqual('foo');
- expect(example.class.array.length).toEqual(0);
+ expect(example.class.constructor.name).toBe('Bar');
+ expect(example.class.foo.name).toBe('foo');
+ expect(example.class.array.length).toBe(0);
// creates a deeply cloned version of the original object.
expect(example.object).toEqual({
@@ -206,12 +206,12 @@ test('should run example code', () => {
});
// creates a new empty array, ignoring the original array.
- expect(example.array.length).toEqual(0);
+ expect(example.array.length).toBe(0);
// creates a new property with the same primitive value as the original property.
- expect(example.number).toEqual(123);
- expect(example.string).toEqual('baz');
- expect(example.boolean).toEqual(true);
+ expect(example.number).toBe(123);
+ expect(example.string).toBe('baz');
+ expect(example.boolean).toBe(true);
expect(example.symbol).toEqual(Symbol.for('a.b.c'));
});
```
@@ -306,7 +306,7 @@ test('moduleName 1', () => {
return jest.fn(() => 1);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(1);
+ expect(moduleName()).toBe(1);
});
test('moduleName 2', () => {
@@ -314,7 +314,7 @@ test('moduleName 2', () => {
return jest.fn(() => 2);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(2);
+ expect(moduleName()).toBe(2);
});
```
@@ -338,8 +338,8 @@ test('moduleName 1', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default1');
- expect(moduleName.foo).toEqual('foo1');
+ expect(moduleName.default).toBe('default1');
+ expect(moduleName.foo).toBe('foo1');
});
});
@@ -352,8 +352,8 @@ test('moduleName 2', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default2');
- expect(moduleName.foo).toEqual('foo2');
+ expect(moduleName.default).toBe('default2');
+ expect(moduleName.foo).toBe('foo2');
});
});
```
diff --git a/website/versioned_docs/version-27.x/MockFunctionAPI.md b/website/versioned_docs/version-27.x/MockFunctionAPI.md
index bd2478b98bcd..06fe2512e33b 100644
--- a/website/versioned_docs/version-27.x/MockFunctionAPI.md
+++ b/website/versioned_docs/version-27.x/MockFunctionAPI.md
@@ -447,7 +447,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// However, it will not allow access to `.mock` in TypeScript as it
// is returning `SoundPlayer`. Instead, you can check the calls to a
// method like this fully typed:
- expect(SoundPlayerMock.prototype.playSoundFile.mock.calls[0][0]).toEqual(
+ expect(SoundPlayerMock.prototype.playSoundFile.mock.calls[0][0]).toBe(
coolSoundFileName,
);
// Equivalent to above check:
diff --git a/website/versioned_docs/version-27.x/MockFunctions.md b/website/versioned_docs/version-27.x/MockFunctions.md
index 006948cc6e9d..66917c956dd0 100644
--- a/website/versioned_docs/version-27.x/MockFunctions.md
+++ b/website/versioned_docs/version-27.x/MockFunctions.md
@@ -74,7 +74,7 @@ expect(someMockFunction.mock.instances.length).toBe(2);
// The object returned by the first instantiation of this function
// had a `name` property whose value was set to 'test'
-expect(someMockFunction.mock.instances[0].name).toEqual('test');
+expect(someMockFunction.mock.instances[0].name).toBe('test');
// The first argument of the last call to the function was 'test'
expect(someMockFunction.mock.lastCall[0]).toBe('test');
diff --git a/website/versioned_docs/version-27.x/TutorialAsync.md b/website/versioned_docs/version-27.x/TutorialAsync.md
index e4c7117c16dc..80acc323a22e 100644
--- a/website/versioned_docs/version-27.x/TutorialAsync.md
+++ b/website/versioned_docs/version-27.x/TutorialAsync.md
@@ -68,7 +68,7 @@ import * as user from '../user';
// The assertion for a promise must be returned.
it('works with promises', () => {
expect.assertions(1);
- return user.getUserName(4).then(data => expect(data).toEqual('Mark'));
+ return user.getUserName(4).then(data => expect(data).toBe('Mark'));
});
```
@@ -81,7 +81,7 @@ There is a less verbose way using `resolves` to unwrap the value of a fulfilled
```js
it('works with resolves', () => {
expect.assertions(1);
- return expect(user.getUserName(5)).resolves.toEqual('Paul');
+ return expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
@@ -94,13 +94,13 @@ Writing tests using the `async`/`await` syntax is also possible. Here is how you
it('works with async/await', async () => {
expect.assertions(1);
const data = await user.getUserName(4);
- expect(data).toEqual('Mark');
+ expect(data).toBe('Mark');
});
// async/await can also be used with `.resolves`.
it('works with async/await and resolves', async () => {
expect.assertions(1);
- await expect(user.getUserName(5)).resolves.toEqual('Paul');
+ await expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
diff --git a/website/versioned_docs/version-27.x/TutorialReact.md b/website/versioned_docs/version-27.x/TutorialReact.md
index 1166dc5a6c60..f40e21deadb7 100644
--- a/website/versioned_docs/version-27.x/TutorialReact.md
+++ b/website/versioned_docs/version-27.x/TutorialReact.md
@@ -268,11 +268,11 @@ test('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkbox = shallow();
- expect(checkbox.text()).toEqual('Off');
+ expect(checkbox.text()).toBe('Off');
checkbox.find('input').simulate('change');
- expect(checkbox.text()).toEqual('On');
+ expect(checkbox.text()).toBe('On');
});
```
diff --git a/website/versioned_docs/version-27.x/TutorialjQuery.md b/website/versioned_docs/version-27.x/TutorialjQuery.md
index 13a309ec4763..d6f32d3c74f6 100644
--- a/website/versioned_docs/version-27.x/TutorialjQuery.md
+++ b/website/versioned_docs/version-27.x/TutorialjQuery.md
@@ -55,7 +55,7 @@ test('displays a user after a click', () => {
// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
- expect($('#username').text()).toEqual('Johnny Cash - Logged In');
+ expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
diff --git a/website/versioned_docs/version-28.x/Es6ClassMocks.md b/website/versioned_docs/version-28.x/Es6ClassMocks.md
index bf81bec755ec..529f4014ea7a 100644
--- a/website/versioned_docs/version-28.x/Es6ClassMocks.md
+++ b/website/versioned_docs/version-28.x/Es6ClassMocks.md
@@ -81,7 +81,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// mock.instances is available with automatic mocks:
const mockSoundPlayerInstance = SoundPlayer.mock.instances[0];
const mockPlaySoundFile = mockSoundPlayerInstance.playSoundFile;
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
// Equivalent to above check:
expect(mockPlaySoundFile).toHaveBeenCalledWith(coolSoundFileName);
expect(mockPlaySoundFile).toHaveBeenCalledTimes(1);
@@ -349,7 +349,7 @@ jest.mock('./sound-player', () => {
});
```
-This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toEqual(1);`
+This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBe(1);`
### Mocking non-default class exports
@@ -444,6 +444,6 @@ it('We can check if the consumer called a method on the class instance', () => {
const soundPlayerConsumer = new SoundPlayerConsumer();
const coolSoundFileName = 'song.mp3';
soundPlayerConsumer.playSomethingCool();
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
});
```
diff --git a/website/versioned_docs/version-28.x/JestObjectAPI.md b/website/versioned_docs/version-28.x/JestObjectAPI.md
index 026919e0bff2..0c19fbb9755b 100644
--- a/website/versioned_docs/version-28.x/JestObjectAPI.md
+++ b/website/versioned_docs/version-28.x/JestObjectAPI.md
@@ -121,7 +121,7 @@ utils.isAuthorized = jest.fn(secret => secret === 'not wizard');
test('implementation created by jest.createMockFromModule', () => {
expect(utils.authorize.mock).toBeTruthy();
- expect(utils.isAuthorized('not wizard')).toEqual(true);
+ expect(utils.isAuthorized('not wizard')).toBe(true);
});
```
@@ -184,17 +184,17 @@ const example = jest.createMockFromModule('./example');
test('should run example code', () => {
// creates a new mocked function with no formal arguments.
- expect(example.function.name).toEqual('square');
- expect(example.function.length).toEqual(0);
+ expect(example.function.name).toBe('square');
+ expect(example.function.length).toBe(0);
// async functions get the same treatment as standard synchronous functions.
- expect(example.asyncFunction.name).toEqual('asyncSquare');
- expect(example.asyncFunction.length).toEqual(0);
+ expect(example.asyncFunction.name).toBe('asyncSquare');
+ expect(example.asyncFunction.length).toBe(0);
// creates a new class with the same interface, member functions and properties are mocked.
- expect(example.class.constructor.name).toEqual('Bar');
- expect(example.class.foo.name).toEqual('foo');
- expect(example.class.array.length).toEqual(0);
+ expect(example.class.constructor.name).toBe('Bar');
+ expect(example.class.foo.name).toBe('foo');
+ expect(example.class.array.length).toBe(0);
// creates a deeply cloned version of the original object.
expect(example.object).toEqual({
@@ -206,12 +206,12 @@ test('should run example code', () => {
});
// creates a new empty array, ignoring the original array.
- expect(example.array.length).toEqual(0);
+ expect(example.array.length).toBe(0);
// creates a new property with the same primitive value as the original property.
- expect(example.number).toEqual(123);
- expect(example.string).toEqual('baz');
- expect(example.boolean).toEqual(true);
+ expect(example.number).toBe(123);
+ expect(example.string).toBe('baz');
+ expect(example.boolean).toBe(true);
expect(example.symbol).toEqual(Symbol.for('a.b.c'));
});
```
@@ -306,7 +306,7 @@ test('moduleName 1', () => {
return jest.fn(() => 1);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(1);
+ expect(moduleName()).toBe(1);
});
test('moduleName 2', () => {
@@ -314,7 +314,7 @@ test('moduleName 2', () => {
return jest.fn(() => 2);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(2);
+ expect(moduleName()).toBe(2);
});
```
@@ -338,8 +338,8 @@ test('moduleName 1', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default1');
- expect(moduleName.foo).toEqual('foo1');
+ expect(moduleName.default).toBe('default1');
+ expect(moduleName.foo).toBe('foo1');
});
});
@@ -352,8 +352,8 @@ test('moduleName 2', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default2');
- expect(moduleName.foo).toEqual('foo2');
+ expect(moduleName.default).toBe('default2');
+ expect(moduleName.foo).toBe('foo2');
});
});
```
diff --git a/website/versioned_docs/version-28.x/MockFunctions.md b/website/versioned_docs/version-28.x/MockFunctions.md
index 51b73f9d77f0..40584bc853d3 100644
--- a/website/versioned_docs/version-28.x/MockFunctions.md
+++ b/website/versioned_docs/version-28.x/MockFunctions.md
@@ -79,7 +79,7 @@ expect(someMockFunction.mock.instances.length).toBe(2);
// The object returned by the first instantiation of this function
// had a `name` property whose value was set to 'test'
-expect(someMockFunction.mock.instances[0].name).toEqual('test');
+expect(someMockFunction.mock.instances[0].name).toBe('test');
// The first argument of the last call to the function was 'test'
expect(someMockFunction.mock.lastCall[0]).toBe('test');
diff --git a/website/versioned_docs/version-28.x/TutorialAsync.md b/website/versioned_docs/version-28.x/TutorialAsync.md
index e4c7117c16dc..80acc323a22e 100644
--- a/website/versioned_docs/version-28.x/TutorialAsync.md
+++ b/website/versioned_docs/version-28.x/TutorialAsync.md
@@ -68,7 +68,7 @@ import * as user from '../user';
// The assertion for a promise must be returned.
it('works with promises', () => {
expect.assertions(1);
- return user.getUserName(4).then(data => expect(data).toEqual('Mark'));
+ return user.getUserName(4).then(data => expect(data).toBe('Mark'));
});
```
@@ -81,7 +81,7 @@ There is a less verbose way using `resolves` to unwrap the value of a fulfilled
```js
it('works with resolves', () => {
expect.assertions(1);
- return expect(user.getUserName(5)).resolves.toEqual('Paul');
+ return expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
@@ -94,13 +94,13 @@ Writing tests using the `async`/`await` syntax is also possible. Here is how you
it('works with async/await', async () => {
expect.assertions(1);
const data = await user.getUserName(4);
- expect(data).toEqual('Mark');
+ expect(data).toBe('Mark');
});
// async/await can also be used with `.resolves`.
it('works with async/await and resolves', async () => {
expect.assertions(1);
- await expect(user.getUserName(5)).resolves.toEqual('Paul');
+ await expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
diff --git a/website/versioned_docs/version-28.x/TutorialReact.md b/website/versioned_docs/version-28.x/TutorialReact.md
index 47404735116d..15d3026dea09 100644
--- a/website/versioned_docs/version-28.x/TutorialReact.md
+++ b/website/versioned_docs/version-28.x/TutorialReact.md
@@ -282,11 +282,11 @@ it('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkbox = shallow();
- expect(checkbox.text()).toEqual('Off');
+ expect(checkbox.text()).toBe('Off');
checkbox.find('input').simulate('change');
- expect(checkbox.text()).toEqual('On');
+ expect(checkbox.text()).toBe('On');
});
```
diff --git a/website/versioned_docs/version-28.x/TutorialjQuery.md b/website/versioned_docs/version-28.x/TutorialjQuery.md
index 99a7bb63979d..9f1be7caf513 100644
--- a/website/versioned_docs/version-28.x/TutorialjQuery.md
+++ b/website/versioned_docs/version-28.x/TutorialjQuery.md
@@ -55,7 +55,7 @@ test('displays a user after a click', () => {
// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
- expect($('#username').text()).toEqual('Johnny Cash - Logged In');
+ expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
diff --git a/website/versioned_docs/version-29.0/Es6ClassMocks.md b/website/versioned_docs/version-29.0/Es6ClassMocks.md
index bf81bec755ec..529f4014ea7a 100644
--- a/website/versioned_docs/version-29.0/Es6ClassMocks.md
+++ b/website/versioned_docs/version-29.0/Es6ClassMocks.md
@@ -81,7 +81,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// mock.instances is available with automatic mocks:
const mockSoundPlayerInstance = SoundPlayer.mock.instances[0];
const mockPlaySoundFile = mockSoundPlayerInstance.playSoundFile;
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
// Equivalent to above check:
expect(mockPlaySoundFile).toHaveBeenCalledWith(coolSoundFileName);
expect(mockPlaySoundFile).toHaveBeenCalledTimes(1);
@@ -349,7 +349,7 @@ jest.mock('./sound-player', () => {
});
```
-This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toEqual(1);`
+This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBe(1);`
### Mocking non-default class exports
@@ -444,6 +444,6 @@ it('We can check if the consumer called a method on the class instance', () => {
const soundPlayerConsumer = new SoundPlayerConsumer();
const coolSoundFileName = 'song.mp3';
soundPlayerConsumer.playSomethingCool();
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
});
```
diff --git a/website/versioned_docs/version-29.0/JestObjectAPI.md b/website/versioned_docs/version-29.0/JestObjectAPI.md
index 2f25365cabc5..0c8f0a51c5f5 100644
--- a/website/versioned_docs/version-29.0/JestObjectAPI.md
+++ b/website/versioned_docs/version-29.0/JestObjectAPI.md
@@ -208,17 +208,17 @@ const example = jest.createMockFromModule('../example');
test('should run example code', () => {
// creates a new mocked function with no formal arguments.
- expect(example.function.name).toEqual('square');
- expect(example.function.length).toEqual(0);
+ expect(example.function.name).toBe('square');
+ expect(example.function.length).toBe(0);
// async functions get the same treatment as standard synchronous functions.
- expect(example.asyncFunction.name).toEqual('asyncSquare');
- expect(example.asyncFunction.length).toEqual(0);
+ expect(example.asyncFunction.name).toBe('asyncSquare');
+ expect(example.asyncFunction.length).toBe(0);
// creates a new class with the same interface, member functions and properties are mocked.
- expect(example.class.constructor.name).toEqual('Bar');
- expect(example.class.foo.name).toEqual('foo');
- expect(example.class.array.length).toEqual(0);
+ expect(example.class.constructor.name).toBe('Bar');
+ expect(example.class.foo.name).toBe('foo');
+ expect(example.class.array.length).toBe(0);
// creates a deeply cloned version of the original object.
expect(example.object).toEqual({
@@ -230,12 +230,12 @@ test('should run example code', () => {
});
// creates a new empty array, ignoring the original array.
- expect(example.array.length).toEqual(0);
+ expect(example.array.length).toBe(0);
// creates a new property with the same primitive value as the original property.
- expect(example.number).toEqual(123);
- expect(example.string).toEqual('baz');
- expect(example.boolean).toEqual(true);
+ expect(example.number).toBe(123);
+ expect(example.string).toBe('baz');
+ expect(example.boolean).toBe(true);
expect(example.symbol).toEqual(Symbol.for('a.b.c'));
});
```
@@ -348,7 +348,7 @@ test('moduleName 1', () => {
return jest.fn(() => 1);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(1);
+ expect(moduleName()).toBe(1);
});
test('moduleName 2', () => {
@@ -356,7 +356,7 @@ test('moduleName 2', () => {
return jest.fn(() => 2);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(2);
+ expect(moduleName()).toBe(2);
});
```
@@ -380,8 +380,8 @@ test('moduleName 1', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default1');
- expect(moduleName.foo).toEqual('foo1');
+ expect(moduleName.default).toBe('default1');
+ expect(moduleName.foo).toBe('foo1');
});
});
@@ -394,8 +394,8 @@ test('moduleName 2', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default2');
- expect(moduleName.foo).toEqual('foo2');
+ expect(moduleName.default).toBe('default2');
+ expect(moduleName.foo).toBe('foo2');
});
});
```
diff --git a/website/versioned_docs/version-29.0/MockFunctions.md b/website/versioned_docs/version-29.0/MockFunctions.md
index 51b73f9d77f0..40584bc853d3 100644
--- a/website/versioned_docs/version-29.0/MockFunctions.md
+++ b/website/versioned_docs/version-29.0/MockFunctions.md
@@ -79,7 +79,7 @@ expect(someMockFunction.mock.instances.length).toBe(2);
// The object returned by the first instantiation of this function
// had a `name` property whose value was set to 'test'
-expect(someMockFunction.mock.instances[0].name).toEqual('test');
+expect(someMockFunction.mock.instances[0].name).toBe('test');
// The first argument of the last call to the function was 'test'
expect(someMockFunction.mock.lastCall[0]).toBe('test');
diff --git a/website/versioned_docs/version-29.0/TutorialAsync.md b/website/versioned_docs/version-29.0/TutorialAsync.md
index e4c7117c16dc..80acc323a22e 100644
--- a/website/versioned_docs/version-29.0/TutorialAsync.md
+++ b/website/versioned_docs/version-29.0/TutorialAsync.md
@@ -68,7 +68,7 @@ import * as user from '../user';
// The assertion for a promise must be returned.
it('works with promises', () => {
expect.assertions(1);
- return user.getUserName(4).then(data => expect(data).toEqual('Mark'));
+ return user.getUserName(4).then(data => expect(data).toBe('Mark'));
});
```
@@ -81,7 +81,7 @@ There is a less verbose way using `resolves` to unwrap the value of a fulfilled
```js
it('works with resolves', () => {
expect.assertions(1);
- return expect(user.getUserName(5)).resolves.toEqual('Paul');
+ return expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
@@ -94,13 +94,13 @@ Writing tests using the `async`/`await` syntax is also possible. Here is how you
it('works with async/await', async () => {
expect.assertions(1);
const data = await user.getUserName(4);
- expect(data).toEqual('Mark');
+ expect(data).toBe('Mark');
});
// async/await can also be used with `.resolves`.
it('works with async/await and resolves', async () => {
expect.assertions(1);
- await expect(user.getUserName(5)).resolves.toEqual('Paul');
+ await expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
diff --git a/website/versioned_docs/version-29.0/TutorialReact.md b/website/versioned_docs/version-29.0/TutorialReact.md
index 47404735116d..15d3026dea09 100644
--- a/website/versioned_docs/version-29.0/TutorialReact.md
+++ b/website/versioned_docs/version-29.0/TutorialReact.md
@@ -282,11 +282,11 @@ it('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkbox = shallow();
- expect(checkbox.text()).toEqual('Off');
+ expect(checkbox.text()).toBe('Off');
checkbox.find('input').simulate('change');
- expect(checkbox.text()).toEqual('On');
+ expect(checkbox.text()).toBe('On');
});
```
diff --git a/website/versioned_docs/version-29.0/TutorialjQuery.md b/website/versioned_docs/version-29.0/TutorialjQuery.md
index 99a7bb63979d..9f1be7caf513 100644
--- a/website/versioned_docs/version-29.0/TutorialjQuery.md
+++ b/website/versioned_docs/version-29.0/TutorialjQuery.md
@@ -55,7 +55,7 @@ test('displays a user after a click', () => {
// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
- expect($('#username').text()).toEqual('Johnny Cash - Logged In');
+ expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```
diff --git a/website/versioned_docs/version-29.1/Es6ClassMocks.md b/website/versioned_docs/version-29.1/Es6ClassMocks.md
index bf81bec755ec..529f4014ea7a 100644
--- a/website/versioned_docs/version-29.1/Es6ClassMocks.md
+++ b/website/versioned_docs/version-29.1/Es6ClassMocks.md
@@ -81,7 +81,7 @@ it('We can check if the consumer called a method on the class instance', () => {
// mock.instances is available with automatic mocks:
const mockSoundPlayerInstance = SoundPlayer.mock.instances[0];
const mockPlaySoundFile = mockSoundPlayerInstance.playSoundFile;
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
// Equivalent to above check:
expect(mockPlaySoundFile).toHaveBeenCalledWith(coolSoundFileName);
expect(mockPlaySoundFile).toHaveBeenCalledTimes(1);
@@ -349,7 +349,7 @@ jest.mock('./sound-player', () => {
});
```
-This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toEqual(1);`
+This will let us inspect usage of our mocked class, using `SoundPlayer.mock.calls`: `expect(SoundPlayer).toHaveBeenCalled();` or near-equivalent: `expect(SoundPlayer.mock.calls.length).toBe(1);`
### Mocking non-default class exports
@@ -444,6 +444,6 @@ it('We can check if the consumer called a method on the class instance', () => {
const soundPlayerConsumer = new SoundPlayerConsumer();
const coolSoundFileName = 'song.mp3';
soundPlayerConsumer.playSomethingCool();
- expect(mockPlaySoundFile.mock.calls[0][0]).toEqual(coolSoundFileName);
+ expect(mockPlaySoundFile.mock.calls[0][0]).toBe(coolSoundFileName);
});
```
diff --git a/website/versioned_docs/version-29.1/JestObjectAPI.md b/website/versioned_docs/version-29.1/JestObjectAPI.md
index 03583667d1c0..2bdea97c19c4 100644
--- a/website/versioned_docs/version-29.1/JestObjectAPI.md
+++ b/website/versioned_docs/version-29.1/JestObjectAPI.md
@@ -229,17 +229,17 @@ const example = jest.createMockFromModule('../example');
test('should run example code', () => {
// creates a new mocked function with no formal arguments.
- expect(example.function.name).toEqual('square');
- expect(example.function.length).toEqual(0);
+ expect(example.function.name).toBe('square');
+ expect(example.function.length).toBe(0);
// async functions get the same treatment as standard synchronous functions.
- expect(example.asyncFunction.name).toEqual('asyncSquare');
- expect(example.asyncFunction.length).toEqual(0);
+ expect(example.asyncFunction.name).toBe('asyncSquare');
+ expect(example.asyncFunction.length).toBe(0);
// creates a new class with the same interface, member functions and properties are mocked.
- expect(example.class.constructor.name).toEqual('Bar');
- expect(example.class.foo.name).toEqual('foo');
- expect(example.class.array.length).toEqual(0);
+ expect(example.class.constructor.name).toBe('Bar');
+ expect(example.class.foo.name).toBe('foo');
+ expect(example.class.array.length).toBe(0);
// creates a deeply cloned version of the original object.
expect(example.object).toEqual({
@@ -251,12 +251,12 @@ test('should run example code', () => {
});
// creates a new empty array, ignoring the original array.
- expect(example.array.length).toEqual(0);
+ expect(example.array.length).toBe(0);
// creates a new property with the same primitive value as the original property.
- expect(example.number).toEqual(123);
- expect(example.string).toEqual('baz');
- expect(example.boolean).toEqual(true);
+ expect(example.number).toBe(123);
+ expect(example.string).toBe('baz');
+ expect(example.boolean).toBe(true);
expect(example.symbol).toEqual(Symbol.for('a.b.c'));
});
```
@@ -380,7 +380,7 @@ test('moduleName 1', () => {
return jest.fn(() => 1);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(1);
+ expect(moduleName()).toBe(1);
});
test('moduleName 2', () => {
@@ -388,7 +388,7 @@ test('moduleName 2', () => {
return jest.fn(() => 2);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(2);
+ expect(moduleName()).toBe(2);
});
```
@@ -403,7 +403,7 @@ test('moduleName 1', () => {
return jest.fn(() => 1);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(1);
+ expect(moduleName()).toBe(1);
});
test('moduleName 2', () => {
@@ -411,7 +411,7 @@ test('moduleName 2', () => {
return jest.fn(() => 2);
});
const moduleName = require('../moduleName');
- expect(moduleName()).toEqual(2);
+ expect(moduleName()).toBe(2);
});
```
@@ -435,8 +435,8 @@ test('moduleName 1', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default1');
- expect(moduleName.foo).toEqual('foo1');
+ expect(moduleName.default).toBe('default1');
+ expect(moduleName.foo).toBe('foo1');
});
});
@@ -449,8 +449,8 @@ test('moduleName 2', () => {
};
});
return import('../moduleName').then(moduleName => {
- expect(moduleName.default).toEqual('default2');
- expect(moduleName.foo).toEqual('foo2');
+ expect(moduleName.default).toBe('default2');
+ expect(moduleName.foo).toBe('foo2');
});
});
```
diff --git a/website/versioned_docs/version-29.1/MockFunctions.md b/website/versioned_docs/version-29.1/MockFunctions.md
index 51b73f9d77f0..40584bc853d3 100644
--- a/website/versioned_docs/version-29.1/MockFunctions.md
+++ b/website/versioned_docs/version-29.1/MockFunctions.md
@@ -79,7 +79,7 @@ expect(someMockFunction.mock.instances.length).toBe(2);
// The object returned by the first instantiation of this function
// had a `name` property whose value was set to 'test'
-expect(someMockFunction.mock.instances[0].name).toEqual('test');
+expect(someMockFunction.mock.instances[0].name).toBe('test');
// The first argument of the last call to the function was 'test'
expect(someMockFunction.mock.lastCall[0]).toBe('test');
diff --git a/website/versioned_docs/version-29.1/TutorialAsync.md b/website/versioned_docs/version-29.1/TutorialAsync.md
index e4c7117c16dc..80acc323a22e 100644
--- a/website/versioned_docs/version-29.1/TutorialAsync.md
+++ b/website/versioned_docs/version-29.1/TutorialAsync.md
@@ -68,7 +68,7 @@ import * as user from '../user';
// The assertion for a promise must be returned.
it('works with promises', () => {
expect.assertions(1);
- return user.getUserName(4).then(data => expect(data).toEqual('Mark'));
+ return user.getUserName(4).then(data => expect(data).toBe('Mark'));
});
```
@@ -81,7 +81,7 @@ There is a less verbose way using `resolves` to unwrap the value of a fulfilled
```js
it('works with resolves', () => {
expect.assertions(1);
- return expect(user.getUserName(5)).resolves.toEqual('Paul');
+ return expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
@@ -94,13 +94,13 @@ Writing tests using the `async`/`await` syntax is also possible. Here is how you
it('works with async/await', async () => {
expect.assertions(1);
const data = await user.getUserName(4);
- expect(data).toEqual('Mark');
+ expect(data).toBe('Mark');
});
// async/await can also be used with `.resolves`.
it('works with async/await and resolves', async () => {
expect.assertions(1);
- await expect(user.getUserName(5)).resolves.toEqual('Paul');
+ await expect(user.getUserName(5)).resolves.toBe('Paul');
});
```
diff --git a/website/versioned_docs/version-29.1/TutorialReact.md b/website/versioned_docs/version-29.1/TutorialReact.md
index 47404735116d..15d3026dea09 100644
--- a/website/versioned_docs/version-29.1/TutorialReact.md
+++ b/website/versioned_docs/version-29.1/TutorialReact.md
@@ -282,11 +282,11 @@ it('CheckboxWithLabel changes the text after click', () => {
// Render a checkbox with label in the document
const checkbox = shallow();
- expect(checkbox.text()).toEqual('Off');
+ expect(checkbox.text()).toBe('Off');
checkbox.find('input').simulate('change');
- expect(checkbox.text()).toEqual('On');
+ expect(checkbox.text()).toBe('On');
});
```
diff --git a/website/versioned_docs/version-29.1/TutorialjQuery.md b/website/versioned_docs/version-29.1/TutorialjQuery.md
index 99a7bb63979d..9f1be7caf513 100644
--- a/website/versioned_docs/version-29.1/TutorialjQuery.md
+++ b/website/versioned_docs/version-29.1/TutorialjQuery.md
@@ -55,7 +55,7 @@ test('displays a user after a click', () => {
// Assert that the fetchCurrentUser function was called, and that the
// #username span's inner text was updated as we'd expect it to.
expect(fetchCurrentUser).toBeCalled();
- expect($('#username').text()).toEqual('Johnny Cash - Logged In');
+ expect($('#username').text()).toBe('Johnny Cash - Logged In');
});
```