Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
move test using tsc into an integration test to avoid timeout (elasti…
Browse files Browse the repository at this point in the history
…c#32174)

Fixes elastic#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.
  • Loading branch information
Spencer committed Feb 28, 2019
1 parent dae372c commit 5725b5c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
18 changes: 0 additions & 18 deletions src/core/public/injected_metadata/deep_freeze.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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.
"
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { deepFreeze } from '../../deep_freeze';
import { deepFreeze } from '../../../deep_freeze';

deepFreeze(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
"
`);
});

0 comments on commit 5725b5c

Please sign in to comment.