From 5725b5c2be77debffdeaae724205843ba45175e5 Mon Sep 17 00:00:00 2001 From: Spencer Date: Thu, 28 Feb 2019 11:25:59 -0800 Subject: [PATCH] move test using tsc into an integration test to avoid timeout (#32174) Fixes #31828 To avoid a timeout we've seen fail 11 times since the end of January by moving the test into an integration test. The test starts up TypeScript, so it's clearly an integration test, and by moving it into an integration test it can have more time to run. --- .../injected_metadata/deep_freeze.test.ts | 18 ---------- .../frozen_object_mutation/index.ts | 2 +- .../frozen_object_mutation/tsconfig.json | 0 .../integration_tests/deep_freeze.test.ts | 36 +++++++++++++++++++ 4 files changed, 37 insertions(+), 19 deletions(-) rename src/core/public/injected_metadata/{ => integration_tests}/__fixtures__/frozen_object_mutation/index.ts (95%) rename src/core/public/injected_metadata/{ => integration_tests}/__fixtures__/frozen_object_mutation/tsconfig.json (100%) create mode 100644 src/core/public/injected_metadata/integration_tests/deep_freeze.test.ts diff --git a/src/core/public/injected_metadata/deep_freeze.test.ts b/src/core/public/injected_metadata/deep_freeze.test.ts index 67816426911df..b4531d80d0252 100644 --- a/src/core/public/injected_metadata/deep_freeze.test.ts +++ b/src/core/public/injected_metadata/deep_freeze.test.ts @@ -17,10 +17,6 @@ * under the License. */ -import { resolve } from 'path'; - -import execa from 'execa'; - import { deepFreeze } from './deep_freeze'; it('returns the first argument with all original references', () => { @@ -73,17 +69,3 @@ it('prevents reassigning items in a frozen array', () => { frozen.foo[0] = 2; }).toThrowError(`read only property '0'`); }); - -it('types return values to prevent mutations in typescript', async () => { - await expect( - execa.stdout('tsc', ['--noEmit'], { - cwd: resolve(__dirname, '__fixtures__/frozen_object_mutation'), - }) - ).rejects.toThrowErrorMatchingInlineSnapshot(` -"Command failed: tsc --noEmit - -index.ts(30,11): error TS2540: Cannot assign to 'baz' because it is a read-only property. -index.ts(40,10): error TS2540: Cannot assign to 'bar' because it is a read-only property. -" -`); -}); diff --git a/src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/index.ts b/src/core/public/injected_metadata/integration_tests/__fixtures__/frozen_object_mutation/index.ts similarity index 95% rename from src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/index.ts rename to src/core/public/injected_metadata/integration_tests/__fixtures__/frozen_object_mutation/index.ts index 0be915a4bde1f..9cf394fc2b0be 100644 --- a/src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/index.ts +++ b/src/core/public/injected_metadata/integration_tests/__fixtures__/frozen_object_mutation/index.ts @@ -17,7 +17,7 @@ * under the License. */ -import { deepFreeze } from '../../deep_freeze'; +import { deepFreeze } from '../../../deep_freeze'; deepFreeze( { diff --git a/src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/tsconfig.json b/src/core/public/injected_metadata/integration_tests/__fixtures__/frozen_object_mutation/tsconfig.json similarity index 100% rename from src/core/public/injected_metadata/__fixtures__/frozen_object_mutation/tsconfig.json rename to src/core/public/injected_metadata/integration_tests/__fixtures__/frozen_object_mutation/tsconfig.json diff --git a/src/core/public/injected_metadata/integration_tests/deep_freeze.test.ts b/src/core/public/injected_metadata/integration_tests/deep_freeze.test.ts new file mode 100644 index 0000000000000..36abb125e0ba3 --- /dev/null +++ b/src/core/public/injected_metadata/integration_tests/deep_freeze.test.ts @@ -0,0 +1,36 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you 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 { resolve } from 'path'; + +import execa from 'execa'; + +it('types return values to prevent mutations in typescript', async () => { + await expect( + execa.stdout('tsc', ['--noEmit'], { + cwd: resolve(__dirname, '__fixtures__/frozen_object_mutation'), + }) + ).rejects.toThrowErrorMatchingInlineSnapshot(` +"Command failed: tsc --noEmit + +index.ts(30,11): error TS2540: Cannot assign to 'baz' because it is a read-only property. +index.ts(40,10): error TS2540: Cannot assign to 'bar' because it is a read-only property. +" +`); +});