mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-17 15:36:48 +00:00
fix: Fix jest (#945)
* bug: jest is now fixed * chore: files are included for the eslint * chore: build is fixed * test: jest test are fixed
This commit is contained in:
parent
3f2a4d6eac
commit
a8c5934fc5
6
frontend/babel.config.js
Normal file
6
frontend/babel.config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: [
|
||||||
|
['@babel/preset-env', { targets: { node: 'current' } }],
|
||||||
|
'@babel/preset-typescript',
|
||||||
|
],
|
||||||
|
};
|
||||||
@ -9,12 +9,19 @@ const config: Config.InitialOptions = {
|
|||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'\\.(css|less)$': '<rootDir>/__mocks__/cssMock.ts',
|
'\\.(css|less)$': '<rootDir>/__mocks__/cssMock.ts',
|
||||||
},
|
},
|
||||||
notify: true,
|
globals: {
|
||||||
notifyMode: 'always',
|
extensionsToTreatAsEsm: ['.ts'],
|
||||||
testMatch: ['<rootDir>/src/**/?(*.)(test).(ts|js)?(x)'],
|
'ts-jest': {
|
||||||
transform: {
|
useESM: true,
|
||||||
'\\.(js|jsx|ts|tsx)?$': 'babel-jest',
|
},
|
||||||
},
|
},
|
||||||
|
testMatch: ['<rootDir>/src/**/?(*.)(test).(ts|js)?(x)'],
|
||||||
|
preset: 'ts-jest/presets/js-with-ts-esm',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.(ts|tsx)?$': 'ts-jest',
|
||||||
|
'^.+\\.(js|jsx)$': 'babel-jest',
|
||||||
|
},
|
||||||
|
transformIgnorePatterns: ['node_modules/(?!(lodash-es)/)'],
|
||||||
setupFilesAfterEnv: ['<rootDir>jest.setup.ts'],
|
setupFilesAfterEnv: ['<rootDir>jest.setup.ts'],
|
||||||
testPathIgnorePatterns: ['/node_modules/', '/public/'],
|
testPathIgnorePatterns: ['/node_modules/', '/public/'],
|
||||||
moduleDirectories: ['node_modules', 'src'],
|
moduleDirectories: ['node_modules', 'src'],
|
||||||
|
|||||||
@ -57,7 +57,7 @@
|
|||||||
"i18next": "^21.6.12",
|
"i18next": "^21.6.12",
|
||||||
"i18next-browser-languagedetector": "^6.1.3",
|
"i18next-browser-languagedetector": "^6.1.3",
|
||||||
"i18next-http-backend": "^1.3.2",
|
"i18next-http-backend": "^1.3.2",
|
||||||
"jest": "26.6.0",
|
"jest": "^27.5.1",
|
||||||
"less": "^4.1.2",
|
"less": "^4.1.2",
|
||||||
"less-loader": "^10.2.0",
|
"less-loader": "^10.2.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
@ -107,6 +107,7 @@
|
|||||||
"@babel/preset-typescript": "^7.12.17",
|
"@babel/preset-typescript": "^7.12.17",
|
||||||
"@jest/globals": "^27.5.1",
|
"@jest/globals": "^27.5.1",
|
||||||
"@testing-library/cypress": "^8.0.0",
|
"@testing-library/cypress": "^8.0.0",
|
||||||
|
"@testing-library/react-hooks": "^7.0.2",
|
||||||
"@types/color": "^3.0.3",
|
"@types/color": "^3.0.3",
|
||||||
"@types/compression-webpack-plugin": "^9.0.0",
|
"@types/compression-webpack-plugin": "^9.0.0",
|
||||||
"@types/copy-webpack-plugin": "^8.0.1",
|
"@types/copy-webpack-plugin": "^8.0.1",
|
||||||
@ -155,6 +156,7 @@
|
|||||||
"portfinder-sync": "^0.0.2",
|
"portfinder-sync": "^0.0.2",
|
||||||
"prettier": "2.2.1",
|
"prettier": "2.2.1",
|
||||||
"react-hot-loader": "^4.13.0",
|
"react-hot-loader": "^4.13.0",
|
||||||
|
"ts-jest": "^27.1.4",
|
||||||
"ts-node": "^10.2.1",
|
"ts-node": "^10.2.1",
|
||||||
"typescript-plugin-css-modules": "^3.4.0",
|
"typescript-plugin-css-modules": "^3.4.0",
|
||||||
"webpack-bundle-analyzer": "^4.5.0",
|
"webpack-bundle-analyzer": "^4.5.0",
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* @jest-environment jsdom
|
||||||
|
*/
|
||||||
|
|
||||||
import { expect } from '@jest/globals';
|
import { expect } from '@jest/globals';
|
||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
exports[`Not Found page test should render Not Found page without errors 1`] = `
|
exports[`Not Found page test should render Not Found page without errors 1`] = `
|
||||||
<DocumentFragment>
|
<DocumentFragment>
|
||||||
<div
|
<div
|
||||||
class="sc-gtsrHT VomVY"
|
class="sc-gsDKAQ cLXpIa"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
fill="none"
|
fill="none"
|
||||||
@ -272,21 +272,21 @@ exports[`Not Found page test should render Not Found page without errors 1`] = `
|
|||||||
</defs>
|
</defs>
|
||||||
</svg>
|
</svg>
|
||||||
<div
|
<div
|
||||||
class="sc-hKFxyN dunFuJ"
|
class="sc-hKwDye foaleg"
|
||||||
>
|
>
|
||||||
<p
|
<p
|
||||||
class="sc-dlnjwi cydxLA"
|
class="sc-dkPtRN fcyVIq"
|
||||||
>
|
>
|
||||||
Ah, seems like we reached a dead end!
|
Ah, seems like we reached a dead end!
|
||||||
</p>
|
</p>
|
||||||
<p
|
<p
|
||||||
class="sc-dlnjwi cydxLA"
|
class="sc-dkPtRN fcyVIq"
|
||||||
>
|
>
|
||||||
Page Not Found
|
Page Not Found
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<a
|
<a
|
||||||
class="sc-bdnxRM bYqcho"
|
class="sc-bdvvtL dbTZkj"
|
||||||
href="/application"
|
href="/application"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
|
|||||||
@ -1,42 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* @jest-environment jsdom
|
||||||
|
*/
|
||||||
|
|
||||||
import { expect } from '@jest/globals';
|
import { expect } from '@jest/globals';
|
||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
|
import { renderHook } from '@testing-library/react-hooks';
|
||||||
import TraceFlameGraph from 'container/TraceFlameGraph';
|
import TraceFlameGraph from 'container/TraceFlameGraph';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { Provider } from 'react-redux';
|
||||||
|
import store from 'store';
|
||||||
|
|
||||||
test('loads and displays greeting', () => {
|
test('loads and displays greeting', () => {
|
||||||
const onSpanHover = useState('');
|
const { rerender } = renderHook(() => useState(''));
|
||||||
|
|
||||||
const { asFragment } = render(
|
const { asFragment } = render(
|
||||||
<TraceFlameGraph
|
<Provider store={store}>
|
||||||
{...{
|
<TraceFlameGraph
|
||||||
hoveredSpanId: '',
|
{...{
|
||||||
intervalUnit: { multiplier: 0, name: 'm' },
|
hoveredSpanId: '',
|
||||||
onSpanHover: onSpanHover[1],
|
intervalUnit: { multiplier: 0, name: 'm' },
|
||||||
onSpanSelect: (): void => {},
|
onSpanHover: rerender,
|
||||||
selectedSpanId: '',
|
onSpanSelect: (): void => {},
|
||||||
traceMetaData: {
|
selectedSpanId: '',
|
||||||
globalEnd: 0,
|
traceMetaData: {
|
||||||
globalStart: 0,
|
globalEnd: 0,
|
||||||
levels: 0,
|
globalStart: 0,
|
||||||
spread: 0,
|
levels: 0,
|
||||||
totalSpans: 0,
|
spread: 0,
|
||||||
},
|
totalSpans: 0,
|
||||||
treeData: {
|
},
|
||||||
children: [],
|
treeData: {
|
||||||
id: '',
|
children: [],
|
||||||
name: '',
|
id: '',
|
||||||
serviceColour: '',
|
name: '',
|
||||||
serviceName: '',
|
serviceColour: '#a0e',
|
||||||
startTime: 0,
|
serviceName: '',
|
||||||
tags: [],
|
startTime: 0,
|
||||||
time: 0,
|
tags: [],
|
||||||
value: 0,
|
time: 100,
|
||||||
event: [],
|
value: 100,
|
||||||
hasError: false,
|
event: [],
|
||||||
parent: undefined,
|
hasError: false,
|
||||||
},
|
parent: undefined,
|
||||||
}}
|
},
|
||||||
/>,
|
}}
|
||||||
|
/>
|
||||||
|
</Provider>,
|
||||||
);
|
);
|
||||||
expect(asFragment()).toMatchSnapshot();
|
expect(asFragment()).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,3 +1,17 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`loads and displays greeting 1`] = `<DocumentFragment />`;
|
exports[`loads and displays greeting 1`] = `
|
||||||
|
<DocumentFragment>
|
||||||
|
<div
|
||||||
|
class="sc-gsDKAQ jFDWPs"
|
||||||
|
height="0"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="sc-bdvvtL fyFVjh"
|
||||||
|
title="
|
||||||
|
0 m"
|
||||||
|
width="Infinity"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</DocumentFragment>
|
||||||
|
`;
|
||||||
|
|||||||
@ -22,5 +22,5 @@
|
|||||||
"plugins": [{ "name": "typescript-plugin-css-modules" }]
|
"plugins": [{ "name": "typescript-plugin-css-modules" }]
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules"],
|
"exclude": ["node_modules"],
|
||||||
"include": ["./src"]
|
"include": ["./src", "./babel.config.js", "./jest.config.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
1111
frontend/yarn.lock
1111
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user