Skip to content

Run the Grafana plugin's unit tests in CI - #141

Open
PDGGK wants to merge 1 commit into
apache:masterfrom
PDGGK:ci/grafana-plugin-tests
Open

PDGGK wants to merge 1 commit into
apache:masterfrom
PDGGK:ci/grafana-plugin-tests

Conversation

@PDGGK

@PDGGK PDGGK commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #134 (comment), where I said I would add npm run test:ci and go test to the build job.

The build job's frontend step is named "Build and test frontend" but only runs npm run build, and no step runs the Go tests. So the three Jest suites in src/ and the tests in pkg/plugin never run in CI.

This change:

  • runs npm run test:ci before npm run build
  • adds a Test backend step with go test ./pkg/... after backend-compile.sh. go.sum is not checked in, and the script's go mod tidy is what produces it, so the tests have to come after it.

Checked locally in the same order (Node 22, Go 1.26):

  • npm ci then the Jest run: 3 suites, 38 tests pass
  • go get -u github.com/grafana/grafana-plugin-sdk-go@v0.250.0 && go mod tidy (the dependency part of backend-compile.sh), then go test ./pkg/...: pkg/plugin passes
  • with one assertion broken in tableQuery.test.ts, the Jest run exits 1; with a t.Fatal added to table_query_test.go, go test exits 1

The build job's frontend step is named "Build and test frontend" but only
builds, and nothing runs the Go tests either, so the 38 Jest tests and the
backend tests under pkg/plugin never run in CI.

Run `npm run test:ci` before the frontend build, and `go test ./pkg/...`
after backend-compile.sh, which is what resolves go.sum.

Signed-off-by: Zihan Dai <1436286758@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant