Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip]: correct set tsconfig for mocha test under plugins/code/server/__test__ #34754

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/kbn-plugin-helpers/lib/plugin_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function(root) {
{
root: root,
kibanaRoot: pkg.name === 'x-pack' ? resolve(root, '..') : resolve(root, '../../kibana'),
serverTestPatterns: ['server/**/__tests__/**/*.js'],
serverTestPatterns: ['server/**/__tests__/**/*'],
buildSourcePatterns: buildSourcePatterns,
skipInstallDependencies: false,
id: pkg.name,
Expand Down
3 changes: 3 additions & 0 deletions src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const PROJECTS = [
...glob
.sync('test/plugin_functional/plugins/*/tsconfig.json', { cwd: REPO_ROOT })
.map(path => new Project(resolve(REPO_ROOT, path))),
...glob
.sync('x-pack/plugins/**/__tests__/tsconfig.json', { cwd: REPO_ROOT })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This glob is too expansive, it covers way too many locations, please pick something a little more static (lets stick to a single * max)

.map(path => new Project(resolve(REPO_ROOT, path))),
];

export function filterProjectsByFlag(projectFlag?: string) {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.kibana-plugin-helpers.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"serverTestPatterns": [
"server/**/__tests__/**/*.js",
"plugins/**/__tests__/**/*.js",
"plugins/**/__tests__/**/*",
"!plugins/**/server/**/__tests__/**/*"
],
"buildSourcePatterns": [
Expand Down
4 changes: 1 addition & 3 deletions x-pack/plugins/code/server/__tests__/clone_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,20 @@ function cleanWorkspace() {
}

describe('clone_worker_tests', () => {
// @ts-ignore
before(async () => {
return new Promise(resolve => {
rimraf(serverOptions.repoPath, resolve);
});
});

beforeEach(async function() {
// @ts-ignore
this.timeout(200000);
await prepareProject(
'https://github.com/Microsoft/TypeScript-Node-Starter.git',
path.join(serverOptions.repoPath, 'github.com/Microsoft/TypeScript-Node-Starter')
);
});
// @ts-ignore

after(() => {
return cleanWorkspace();
});
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/code/server/__tests__/git_operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ describe('git_operations', () => {
return repo;
}

// @ts-ignore
before(async () => {
await prepareProject(path.join(serverOptions.repoPath, repoUri));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,19 @@ function setupLsServiceSendRequestSpy(): sinon.SinonSpy {
}

describe('lsp_incremental_indexer unit tests', () => {
// @ts-ignore
before(async () => {
return new Promise(resolve => {
rimraf(serverOptions.repoPath, resolve);
});
});

beforeEach(async function() {
// @ts-ignore
this.timeout(200000);
return await prepareProject(
'https://github.com/Microsoft/TypeScript-Node-Starter.git',
path.join(serverOptions.repoPath, repoUri)
);
});
// @ts-ignore
after(() => {
return cleanWorkspace();
});
Expand Down Expand Up @@ -197,7 +194,6 @@ describe('lsp_incremental_indexer unit tests', () => {
// fitted into a single batch index.
assert.ok(bulkSpy.calledOnce);
assert.strictEqual(bulkSpy.getCall(0).args[0].body.length, 9 * 2);
// @ts-ignore
}).timeout(20000);

it('Cancel LSP index process.', async () => {
Expand Down Expand Up @@ -297,7 +293,5 @@ describe('lsp_incremental_indexer unit tests', () => {
assert.ok(bulkSpy.calledOnce);
assert.strictEqual(bulkSpy.getCall(0).args[0].body.length, 3 * 2);
assert.strictEqual(deleteByQuerySpy.callCount, 2);
// @ts-ignore
}).timeout(20000);
// @ts-ignore
}).timeout(20000);
7 changes: 2 additions & 5 deletions x-pack/plugins/code/server/__tests__/lsp_indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,22 @@ function setupLsServiceSendRequestSpy(): sinon.SinonSpy {
})
);
}

describe('lsp_indexer unit tests', () => {
// @ts-ignore
before(async () => {
return new Promise(resolve => {
rimraf(serverOptions.repoPath, resolve);
});
});

beforeEach(async function() {
// @ts-ignore
this.timeout(200000);
return await prepareProject(
'https://github.com/Microsoft/TypeScript-Node-Starter.git',
path.join(serverOptions.repoPath, repoUri)
);
});
// @ts-ignore

after(() => {
return cleanWorkspace();
});
Expand Down Expand Up @@ -297,7 +296,5 @@ describe('lsp_indexer unit tests', () => {
// single batch index.
assert.ok(bulkSpy.calledOnce);
assert.strictEqual(bulkSpy.getCall(0).args[0].body.length, 33 * 2);
// @ts-ignore
}).timeout(20000);
// @ts-ignore
}).timeout(20000);
3 changes: 0 additions & 3 deletions x-pack/plugins/code/server/__tests__/lsp_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('lsp_service tests', () => {

const repoUri = 'github.com/test/test_repo';

// @ts-ignore
before(async () => {
await prepareProject(path.join(serverOptions.repoPath, repoUri));
});
Expand Down Expand Up @@ -140,7 +139,6 @@ describe('lsp_service tests', () => {
} finally {
await lspservice.shutdown();
}
// @ts-ignore
}).timeout(10000);

it('unload a workspace', async () => {
Expand Down Expand Up @@ -198,6 +196,5 @@ describe('lsp_service tests', () => {
} finally {
await lspservice.shutdown();
}
// @ts-ignore
}).timeout(10000);
});
5 changes: 1 addition & 4 deletions x-pack/plugins/code/server/__tests__/multi_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ describe('code in multiple nodes', () => {
nonCodeNode = createRootWithCorePlugins(setting);
await nonCodeNode.setup();
}
// @ts-ignore

before(startServers);

// @ts-ignore
after(async function() {
// @ts-ignore
this.timeout(10000);
await nonCodeNode.shutdown();
await servers.stop();
Expand All @@ -106,6 +104,5 @@ describe('code in multiple nodes', () => {
await codeNode.setup();
await delay(2000);
await request.get(nonCodeNode, '/api/code/setup').expect(200);
// @ts-ignore
}).timeout(20000);
});
17 changes: 17 additions & 0 deletions x-pack/plugins/code/server/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../../../tsconfig.json",
"compilerOptions": {
// TODO why we have to have this
"resolveJsonModule": true,
"types": [
"mocha",
"node"
]
},
"include": [
// TODO why we have to have this
"../../../../../src/legacy/server/kbn_server.d.ts",
"**/*"
],
"exclude": [],
}
1 change: 0 additions & 1 deletion x-pack/plugins/code/server/lsp/install_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export class InstallManager {
let downloaded = 0;
return await new Promise<string>((resolve, reject) => {
res
// @ts-ignore
.body!.pipe(stream)
.on('error', (error: any) => {
reject(error);
Expand Down
3 changes: 2 additions & 1 deletion x-pack/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
],
"exclude": [
"test/**/*",
"**/typespec_tests.ts"
"**/typespec_tests.ts",
"plugins/code/**/__tests__/**/*"
],
"compilerOptions": {
"outDir": ".",
Expand Down