diff --git a/x-pack/plugins/grokdebugger/jest.config.js b/x-pack/plugins/grokdebugger/jest.config.js new file mode 100644 index 0000000000000..bf43870b5ba65 --- /dev/null +++ b/x-pack/plugins/grokdebugger/jest.config.js @@ -0,0 +1,11 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/x-pack/plugins/grokdebugger'], +}; diff --git a/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.test.js similarity index 83% rename from x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.test.js index 2e0be6001f8ca..0644a797da8bd 100644 --- a/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/__tests__/grokdebugger_request.js +++ b/x-pack/plugins/grokdebugger/server/models/grokdebugger_request/grokdebugger_request.test.js @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import expect from '@kbn/expect'; -import { GrokdebuggerRequest } from '../grokdebugger_request'; +import { GrokdebuggerRequest } from './grokdebugger_request'; // FAILING: https://github.com/elastic/kibana/issues/51372 describe.skip('grokdebugger_request', () => { @@ -24,18 +23,18 @@ describe.skip('grokdebugger_request', () => { describe('fromDownstreamJSON factory method', () => { it('returns correct GrokdebuggerRequest instance from downstreamRequest', () => { const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(downstreamRequest); - expect(grokdebuggerRequest.rawEvent).to.eql(downstreamRequest.rawEvent); - expect(grokdebuggerRequest.pattern).to.eql(downstreamRequest.pattern); - expect(grokdebuggerRequest.customPatterns).to.eql({}); + expect(grokdebuggerRequest.rawEvent).toEqual(downstreamRequest.rawEvent); + expect(grokdebuggerRequest.pattern).toEqual(downstreamRequest.pattern); + expect(grokdebuggerRequest.customPatterns).toEqual({}); }); it('returns correct GrokdebuggerRequest instance from downstreamRequest when custom patterns are specified', () => { const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON( downstreamRequestWithCustomPatterns ); - expect(grokdebuggerRequest.rawEvent).to.eql(downstreamRequest.rawEvent); - expect(grokdebuggerRequest.pattern).to.eql(downstreamRequest.pattern); - expect(grokdebuggerRequest.customPatterns).to.eql('%{FOO:bar}'); + expect(grokdebuggerRequest.rawEvent).toEqual(downstreamRequest.rawEvent); + expect(grokdebuggerRequest.pattern).toEqual(downstreamRequest.pattern); + expect(grokdebuggerRequest.customPatterns).toEqual('%{FOO:bar}'); }); }); @@ -67,7 +66,7 @@ describe.skip('grokdebugger_request', () => { }; const grokdebuggerRequest = GrokdebuggerRequest.fromDownstreamJSON(downstreamRequest); const upstreamJson = grokdebuggerRequest.upstreamJSON; - expect(upstreamJson).to.eql(expectedUpstreamJSON); + expect(upstreamJson).toEqual(expectedUpstreamJSON); }); it('returns the upstream simulate JSON request when custom patterns are specified', () => { @@ -99,7 +98,7 @@ describe.skip('grokdebugger_request', () => { downstreamRequestWithCustomPatterns ); const upstreamJson = grokdebuggerRequest.upstreamJSON; - expect(upstreamJson).to.eql(expectedUpstreamJSON); + expect(upstreamJson).toEqual(expectedUpstreamJSON); }); }); }); diff --git a/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js b/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.test.js similarity index 85% rename from x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js rename to x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.test.js index 3dde3244ed19b..de550b3f9bccd 100644 --- a/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/__tests__/grokdebugger_response.js +++ b/x-pack/plugins/grokdebugger/server/models/grokdebugger_response/grokdebugger_response.test.js @@ -4,8 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import expect from '@kbn/expect'; -import { GrokdebuggerResponse } from '../grokdebugger_response'; +import { GrokdebuggerResponse } from './grokdebugger_response'; describe('grokdebugger_response', () => { describe('GrokdebuggerResponse', () => { @@ -37,8 +36,8 @@ describe('grokdebugger_response', () => { client: '55.3.244.1', }; const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(upstreamJson); - expect(grokdebuggerResponse.structuredEvent).to.eql(expectedStructuredEvent); - expect(grokdebuggerResponse.error).to.eql({}); + expect(grokdebuggerResponse.structuredEvent).toEqual(expectedStructuredEvent); + expect(grokdebuggerResponse.error).toEqual({}); }); it('returns correct GrokdebuggerResponse instance when there are valid grok parse errors', () => { @@ -61,8 +60,8 @@ describe('grokdebugger_response', () => { ], }; const grokdebuggerResponse = GrokdebuggerResponse.fromUpstreamJSON(upstreamJson); - expect(grokdebuggerResponse.structuredEvent).to.eql({}); - expect(grokdebuggerResponse.error).to.be( + expect(grokdebuggerResponse.structuredEvent).toEqual({}); + expect(grokdebuggerResponse.error).toBe( 'Provided Grok patterns do not match data in the input' ); });