Skip to content

Commit d617516

Browse files
authored
Merge pull request #64 from grafana/kevinwcyu/node-18
Support Node 18
2 parents 1764267 + 0a4a16c commit d617516

File tree

7 files changed

+763
-4227
lines changed

7 files changed

+763
-4227
lines changed

.drone.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ platform:
1111

1212
steps:
1313
- name: initialize
14-
image: grafana/grafana-plugin-ci:1.5.1-alpine
14+
image: grafana/grafana-plugin-ci:1.9.5
1515
commands:
16+
- . ~/.init-nvm.sh
1617
- mkdir -p bin
1718
- curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v0.5.27/grabpl
1819
- chmod +x bin/grabpl
@@ -21,16 +22,17 @@ steps:
2122
- rm -rf node_modules/@grafana/data/node_modules
2223

2324
- name: build-and-test-frontend
24-
image: grafana/grafana-plugin-ci:1.5.1-alpine
25+
image: grafana/grafana-plugin-ci:1.9.5
2526
commands:
27+
- . ~/.init-nvm.sh
2628
- yarn eslint ./src --ext .js,.jsx,.ts,.tsx
2729
- yarn build
28-
- yarn test-ci
30+
- yarn test:ci
2931
depends_on:
3032
- initialize
3133

3234
---
3335
kind: signature
34-
hmac: 4f7eaf8336ad46a783436864368ed391cb4aade800bf4cc586df0c9cbfcc97e3
36+
hmac: 16f1768e2d0075f7fb84f8766c2995371afe84ffbc15d06e90dfa7f8ed8ff97d
3537

3638
...

.github/workflows/publish-npm.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727

2828
- name: Setup .npmrc file for NPM registry
2929
if: steps.version_check.outputs.changed == 'true'
30-
uses: actions/setup-node@v2
30+
- uses: actions/setup-node@v3
3131
with:
32-
node-version: '16'
32+
node-version-file: '.nvmrc'
3333
registry-url: 'https://registry.npmjs.org'
3434

3535
- name: Install dependencies
@@ -48,9 +48,9 @@ jobs:
4848

4949
- name: Setup .npmrc file for GitHub Packages
5050
if: steps.version_check.outputs.changed == 'true'
51-
uses: actions/setup-node@v2
51+
- uses: actions/setup-node@v3
5252
with:
53-
node-version: '16'
53+
node-version-file: '.nvmrc'
5454
registry-url: 'https://npm.pkg.github.com'
5555
scope: '@grafana'
5656

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

jest.config.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
// This file is needed because it is used by vscode and other tools that
22
// call `jest` directly. However, unless you are doing anything special
33
// do not edit this file
4+
module.exports = {
5+
modulePaths: ['<rootDir>/src'],
6+
setupFilesAfterEnv: ['<rootDir>/src/tests/setupTests.ts'],
7+
testEnvironment: 'jest-environment-jsdom',
8+
testMatch: [
9+
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
10+
'<rootDir>/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx}',
11+
'<rootDir>/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx}',
12+
],
13+
transform: {
14+
'^.+\\.(t|j)sx?$': [
15+
'@swc/jest',
16+
{
17+
sourceMaps: true,
18+
jsc: {
19+
parser: {
20+
syntax: 'typescript',
21+
tsx: true,
22+
decorators: false,
23+
dynamicImport: true,
24+
},
25+
},
26+
},
27+
],
28+
},
29+
transformIgnorePatterns: [],
30+
};
431

5-
const standard = require('@grafana/toolkit/src/config/jest.plugin.config');
6-
7-
const config = standard.jestConfig();
8-
9-
// allows us to have our own custom set up test file
10-
config.setupFilesAfterEnv = ['<rootDir>/src/tests/setupTests.ts'];
11-
12-
// This process will use the same config that `yarn test` is using
13-
module.exports = config;

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"typecheck": "tsc -p ./tsconfig.build.json",
1818
"test": "jest --notify --watch",
1919
"test:coverage": "jest --coverage",
20-
"test-ci": "grafana-toolkit plugin:test"
20+
"test:ci": "jest"
2121
},
2222
"files": [
2323
"dist"
@@ -31,10 +31,12 @@
3131
},
3232
"devDependencies": {
3333
"@grafana/data": "9.4.14",
34+
"@grafana/eslint-config": "^6.0.1",
3435
"@grafana/runtime": "9.4.14",
35-
"@grafana/toolkit": "9.4.14",
3636
"@grafana/ui": "9.4.14",
3737
"@rollup/plugin-node-resolve": "^15.0.1",
38+
"@swc/core": "^1.3.93",
39+
"@swc/jest": "^0.2.29",
3840
"@testing-library/jest-dom": "5.16.5",
3941
"@testing-library/react": "12.1.5",
4042
"@testing-library/react-hooks": "8.0.1",
@@ -43,7 +45,12 @@
4345
"@types/node": "16.18.6",
4446
"@types/react": "17.0.42",
4547
"@types/react-dom": "17.0.14",
48+
"@typescript-eslint/eslint-plugin": "^5.48.0",
4649
"esbuild": "^0.16.2",
50+
"eslint": "^8.49.0",
51+
"eslint-plugin-jsdoc": "^46.7.0",
52+
"eslint-plugin-react": "^7.31.11",
53+
"eslint-plugin-react-hooks": "^4.6.0",
4754
"jest": "27.5.1",
4855
"node-notifier": "^10.0.1",
4956
"react": "17.0.2",

src/tests/setupTests.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
// enables assertions such as toBeInTheDocument to be used in our tests
22
import '@testing-library/jest-dom';
3+
4+
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
5+
Object.defineProperty(global, 'matchMedia', {
6+
writable: true,
7+
value: jest.fn().mockImplementation((query) => ({
8+
matches: false,
9+
media: query,
10+
onchange: null,
11+
addListener: jest.fn(), // deprecated
12+
removeListener: jest.fn(), // deprecated
13+
addEventListener: jest.fn(),
14+
removeEventListener: jest.fn(),
15+
dispatchEvent: jest.fn(),
16+
})),
17+
});

0 commit comments

Comments
 (0)