chore: restore expect.any()/expect.anything() (#12820)

This commit is contained in:
Max Schmitt 2022-03-16 21:34:41 +01:00 committed by GitHub
parent bb68875e82
commit e231db1810
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 10 deletions

View File

@ -34,6 +34,8 @@ export declare type Expect = {
extend(arg0: any): void;
getState(): expect.MatcherState;
setState(state: Partial<expect.MatcherState>): void;
any(expectedObject: any): AsymmetricMatcher;
anything(): AsymmetricMatcher;
arrayContaining(sample: Array<unknown>): AsymmetricMatcher;
objectContaining(sample: Record<string, unknown>): AsymmetricMatcher;
stringContaining(expected: string): AsymmetricMatcher;
@ -43,8 +45,6 @@ export declare type Expect = {
* - assertions()
* - extractExpectedAssertionsErrors()
* hasAssertions()
* - any()
* - anything()
*/
};

View File

@ -118,17 +118,31 @@ test('should include custom error message with web-first assertions', async ({ r
].join('\n'));
});
test('should work with default expect prototype functions', async ({ runTSC }) => {
const result = await runTSC({
'a.spec.ts': `
const { test } = pwt;
test('should work with default expect prototype functions', async ({ runTSC, runInlineTest }) => {
const spec = `
const { test } = pwt;
test('pass', async () => {
const expected = [1, 2, 3, 4, 5, 6];
test.expect([4, 1, 6, 7, 3, 5, 2, 5, 4, 6]).toEqual(
expect.arrayContaining(expected),
);
`
});
expect(result.exitCode).toBe(0);
expect('foo').toEqual(expect.any(String));
expect('foo').toEqual(expect.anything());
});
`;
{
const result = await runTSC({
'a.spec.ts': spec,
});
expect(result.exitCode).toBe(0);
}
{
const result = await runInlineTest({
'a.spec.ts': spec,
});
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
}
});
test('should work with default expect matchers', async ({ runTSC }) => {

View File

@ -241,7 +241,8 @@ const TSCONFIG = {
'esModuleInterop': true,
'allowSyntheticDefaultImports': true,
'rootDir': '.',
'lib': ['esnext', 'dom', 'DOM.Iterable']
'lib': ['esnext', 'dom', 'DOM.Iterable'],
'noEmit': true,
},
'exclude': [
'node_modules'