Skip to content

Commit

Permalink
[7.10] [mocha] find tests in ts files too (#85515) (#85609)
Browse files Browse the repository at this point in the history
Co-authored-by: Spencer Alger <[email protected]>
Co-authored-by: Tyler Smalley <[email protected]>

Co-authored-by: Spencer Alger <[email protected]>
Co-authored-by: Tyler Smalley <[email protected]>
  • Loading branch information
3 people authored Dec 10, 2020
1 parent 9916c94 commit 0ff038d
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('esArchiver: createIndexDocRecordsStream()', () => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records),
requestTimeout: 120000,
});
return { ok: true };
},
Expand All @@ -66,13 +67,15 @@ describe('esArchiver: createIndexDocRecordsStream()', () => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(0, 1)),
requestTimeout: 120000,
});
return { ok: true };
},
async (name, params) => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(1)),
requestTimeout: 120000,
});
return { ok: true };
},
Expand Down Expand Up @@ -100,6 +103,7 @@ describe('esArchiver: createIndexDocRecordsStream()', () => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(0, 1)),
requestTimeout: 120000,
});
await delay(delayMs);
return { ok: true };
Expand All @@ -108,6 +112,7 @@ describe('esArchiver: createIndexDocRecordsStream()', () => {
expect(name).to.be('bulk');
expect(params).to.eql({
body: recordsToBulkBody(records.slice(1)),
requestTimeout: 120000,
});
expect(Date.now() - start).to.not.be.lessThan(delayMs);
return { ok: true };
Expand Down
19 changes: 10 additions & 9 deletions src/dev/mocha/run_mocha_cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export function runMochaCli() {
globby
.sync(
[
'src/**/__tests__/**/*.js',
'packages/**/__tests__/**/*.js',
'tasks/**/__tests__/**/*.js',
'x-pack/common/**/__tests__/**/*.js',
'x-pack/server/**/__tests__/**/*.js',
`x-pack/legacy/plugins/*/__tests__/**/*.js`,
`x-pack/legacy/plugins/*/common/**/__tests__/**/*.js`,
`x-pack/legacy/plugins/*/**/server/**/__tests__/**/*.js`,
'src/**/__tests__/**/*.{js,ts,tsx}',
'packages/**/__tests__/**/*.{js,ts,tsx}',
'tasks/**/__tests__/**/*.{js,ts,tsx}',
'x-pack/common/**/__tests__/**/*.{js,ts,tsx}',
'x-pack/server/**/__tests__/**/*.{js,ts,tsx}',
`x-pack/legacy/plugins/*/__tests__/**/*.{js,ts,tsx}`,
`x-pack/legacy/plugins/*/common/**/__tests__/**/*.{js,ts,tsx}`,
`x-pack/legacy/plugins/*/**/server/**/__tests__/**/*.{js,ts,tsx}`,
],
{
cwd: REPO_ROOT,
Expand All @@ -83,7 +83,8 @@ export function runMochaCli() {
ignore: [
'**/__tests__/fixtures/**',
'src/**/public/**',
'**/_*.js',
'**/_*.{js,ts,tsx}',
'**/*.test.*',
'packages/**/target/**',
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { getProxyRouteHandlerDeps } from './mocks';
import expect from '@kbn/expect';
import { Readable } from 'stream';

import { kibanaResponseFactory } from '../../../../../core/server';
import { createHandler } from '../../routes/api/console/proxy/create_handler';
import * as requestModule from '../../lib/proxy_request';
import { kibanaResponseFactory } from '../../../../../../../../core/server';
import { createHandler } from '../create_handler';
import * as requestModule from '../../../../../lib/proxy_request';
import { createResponseStub } from './stubs';

describe('Console Proxy Route', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
jest.mock('../../../../../core/server/http/router/request', () => ({
jest.mock('../../../../../../../../core/server/http/router/request', () => ({
ensureRawRequest: jest.fn(),
}));

import { kibanaResponseFactory } from '../../../../../core/server';
import { kibanaResponseFactory } from '../../../../../../../../core/server';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ensureRawRequest } from '../../../../../core/server/http/router/request';
import { ensureRawRequest } from '../../../../../../../../core/server/http/router/request';

import { getProxyRouteHandlerDeps } from './mocks';

import expect from '@kbn/expect';
import * as requestModule from '../../lib/proxy_request';
import * as requestModule from '../../../../../lib/proxy_request';

import { createHandler } from '../../routes/api/console/proxy/create_handler';
import { createHandler } from '../create_handler';

import { createResponseStub } from './stubs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* under the License.
*/

jest.mock('../../lib/proxy_request', () => ({
jest.mock('../../../../../lib/proxy_request', () => ({
proxyRequest: jest.fn(),
}));

import { duration } from 'moment';
import { ProxyConfigCollection } from '../../lib';
import { RouteDependencies, ProxyDependencies } from '../../routes';
import { EsLegacyConfigService, SpecDefinitionsService } from '../../services';
import { coreMock, httpServiceMock } from '../../../../../core/server/mocks';
import { ProxyConfigCollection } from '../../../../../lib';
import { RouteDependencies, ProxyDependencies } from '../../../../../routes';
import { EsLegacyConfigService, SpecDefinitionsService } from '../../../../../services';
import { coreMock, httpServiceMock } from '../../../../../../../../core/server/mocks';

const defaultProxyValue = Object.freeze({
readLegacyESConfig: async () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
import { kibanaResponseFactory } from '../../../../../core/server';
import { kibanaResponseFactory } from '../../../../../../../../core/server';
import { getProxyRouteHandlerDeps } from './mocks';
import { createResponseStub } from './stubs';
import * as requestModule from '../../lib/proxy_request';
import * as requestModule from '../../../../../lib/proxy_request';
import expect from '@kbn/expect';

import { createHandler } from '../../routes/api/console/proxy/create_handler';
import { createHandler } from '../create_handler';

describe('Console Proxy Route', () => {
let handler: ReturnType<typeof createHandler>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import { duration } from 'moment';
import { getProxyRouteHandlerDeps } from './mocks';

import { kibanaResponseFactory } from '../../../../../core/server';
import { createHandler } from '../../routes/api/console/proxy/create_handler';
import * as requestModule from '../../lib/proxy_request';
import { kibanaResponseFactory } from '../../../../../../../../core/server';
import * as requestModule from '../../../../../lib/proxy_request';
import { createHandler } from '../create_handler';

describe('Console Proxy Route', () => {
afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
import { kibanaResponseFactory } from '../../../../../core/server';
import { kibanaResponseFactory } from '../../../../../../../../core/server';
import { getProxyRouteHandlerDeps } from './mocks';
import { createResponseStub } from './stubs';
import * as requestModule from '../../lib/proxy_request';
import * as requestModule from '../../../../../lib/proxy_request';

import expect from '@kbn/expect';

import { createHandler } from '../../routes/api/console/proxy/create_handler';
import { createHandler } from '../create_handler';

describe('Console Proxy Route', () => {
let request: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { routeValidationConfig } from '../../routes/api/console/proxy/validation_config';
import { routeValidationConfig } from '../validation_config';

const { query } = routeValidationConfig;

Expand Down

0 comments on commit 0ff038d

Please sign in to comment.