chore: add support private methods in TS (#12051)

This commit is contained in:
Pavel Feldman 2022-02-11 14:46:49 -08:00 committed by GitHub
parent aee844eaed
commit 96b5831a49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions

View File

@ -158,6 +158,7 @@ export function transformHook(code: string, filename: string, isModule = false):
[require.resolve('@babel/plugin-proposal-logical-assignment-operators')],
[require.resolve('@babel/plugin-proposal-nullish-coalescing-operator')],
[require.resolve('@babel/plugin-proposal-optional-chaining')],
[require.resolve('@babel/plugin-proposal-private-methods')],
[require.resolve('@babel/plugin-syntax-json-strings')],
[require.resolve('@babel/plugin-syntax-optional-catch-binding')],
[require.resolve('@babel/plugin-syntax-async-generators')],

View File

@ -0,0 +1,38 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { test, expect } from './playwright-test-fixtures';
test('should succeed', async ({ runInlineTest }) => {
const result = await runInlineTest({
'one-success.spec.ts': `
const { test } = pwt;
class Foo {
#logger = 2;
get #log() { return this.#logger; }
value() { return this.#log; };
}
test('succeeds', () => {
expect(new Foo().value()).toBe(2);
});
`
});
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
expect(result.failed).toBe(0);
});