fix tests and types generator (#4746)

# What this PR does
Fix unit tests from irm run 
Fix types generator after Node.js upgrade

## Which issue(s) this PR closes

Related to https://github.com/grafana/irm/issues/25

<!--
*Note*: If you want the issue to be auto-closed once the PR is merged,
change "Related to" to "Closes" in the line above.
If you have more than one GitHub issue that this PR closes, be sure to
preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
This commit is contained in:
Dominik Broj 2024-07-26 17:59:55 +02:00 committed by GitHub
parent 0aa3b1dc33
commit 457d292b0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 5 additions and 6 deletions

View file

@ -1,5 +1,3 @@
const esModules = ['@grafana', 'uplot', 'ol', 'd3', 'react-colorful', 'uuid', 'openapi-fetch'].join('|');
module.exports = { module.exports = {
...require('./.config/jest.config'), ...require('./.config/jest.config'),
testEnvironment: 'jsdom', testEnvironment: 'jsdom',
@ -7,8 +5,6 @@ module.exports = {
moduleDirectories: ['node_modules', 'src'], moduleDirectories: ['node_modules', 'src'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'd.ts', 'cjs'], moduleFileExtensions: ['ts', 'tsx', 'js', 'd.ts', 'cjs'],
transformIgnorePatterns: [`/node_modules/(?!${esModules})`],
moduleNameMapper: { moduleNameMapper: {
'grafana/app/(.*)': '<rootDir>/src/jest/grafanaMock.ts', 'grafana/app/(.*)': '<rootDir>/src/jest/grafanaMock.ts',
'openapi-fetch': '<rootDir>/src/jest/openapiFetchMock.ts', 'openapi-fetch': '<rootDir>/src/jest/openapiFetchMock.ts',

View file

@ -14,6 +14,7 @@
"test-utc": "TZ=UTC jest --verbose --testNamePattern '^((?!@london-tz).)*$'", "test-utc": "TZ=UTC jest --verbose --testNamePattern '^((?!@london-tz).)*$'",
"test-london-tz": "TZ=Europe/London jest --verbose --testNamePattern '@london-tz'", "test-london-tz": "TZ=Europe/London jest --verbose --testNamePattern '@london-tz'",
"test": "yarn test-utc && yarn test-london-tz", "test": "yarn test-utc && yarn test-london-tz",
"test:ci": "yarn test",
"test:report": "HTML_REPORT_ENABLED=true yarn test", "test:report": "HTML_REPORT_ENABLED=true yarn test",
"test:silent": "yarn test --silent", "test:silent": "yarn test --silent",
"test:e2e": "yarn playwright test --grep-invert @expensive", "test:e2e": "yarn playwright test --grep-invert @expensive",

View file

@ -1,6 +1,6 @@
{ {
"type": "module", "type": "module",
"scripts": { "scripts": {
"generate": "npx ts-node-esm -P ./types-generator.tsconfig.json ./generate-types.ts && prettier --write ../autogenerated-api.types.d.ts" "generate": "node --loader ts-node/esm ./generate-types.ts && prettier --write ../autogenerated-api.types.d.ts"
} }
} }

View file

@ -1,7 +1,9 @@
{ {
"compilerOptions": { "compilerOptions": {
"module": "ESNext", "module": "ESNext",
"target": "ESNext",
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true "esModuleInterop": true
} },
"ts-node": { "esm": true }
} }