Skip to content

Commit

Permalink
Add test setup for the @bufbuild/connect-node package (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Mar 27, 2023
1 parent 27bcb7b commit c18d298
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 32 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,16 @@ clean: crosstestserverstop ## Delete build artifacts and installed dependencies
build: $(BUILD)/connect $(BUILD)/connect-web $(BUILD)/connect-node $(BUILD)/connect-fastify $(BUILD)/connect-express $(BUILD)/connect-next $(BUILD)/protoc-gen-connect-es $(BUILD)/protoc-gen-connect-web $(BUILD)/example ## Build

.PHONY: test
test: testcore testnode testwebnode testwebbrowser ## Run all tests, except browserstack
test: testconnectpackage testconnectnodepackage testnode testwebnode testwebbrowser ## Run all tests, except browserstack

.PHONY: testcore
testcore: $(BUILD)/connect
.PHONY: testconnectpackage
testconnectpackage: $(BUILD)/connect
npm run -w packages/connect jasmine

.PHONY: testconnectnodepackage
testconnectnodepackage: $(BUILD)/connect-node
npm run -w packages/connect-node jasmine

.PHONY: testnode
testnode: $(BIN)/node16 $(BIN)/node17 $(BIN)/node18 $(BIN)/node19 $(BUILD)/connect-node-test
$(MAKE) crosstestserverrun
Expand Down
18 changes: 11 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/connect-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
"build": "npm run build:cjs && npm run build:esm+types",
"build:cjs": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
"build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
},
"main": "./dist/cjs/index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
"build": "npm run build:cjs && npm run build:esm+types",
"build:cjs": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
"build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
},
"main": "./dist/cjs/index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
"build": "npm run build:cjs && npm run build:esm+types",
"build:cjs": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
"build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
},
"main": "./dist/cjs/index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-node-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"scripts": {
"clean": "rm -rf ./dist/esm/*",
"generate": "buf generate",
"build": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm",
"jasmine": "../../node_modules/.bin/jasmine --config=jasmine.json"
"build": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm",
"jasmine": "jasmine --config=jasmine.json"
},
"type": "module",
"types": "./dist/types/index.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions packages/connect-node/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/src
/*.json
/dist/*/**/*.spec.js
/dist/*/**/*.spec.d.ts
9 changes: 9 additions & 0 deletions packages/connect-node/jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"spec_dir": "dist/esm",
"spec_files": ["**/*.spec.js"],
"helpers": [],
"env": {
"stopSpecOnExpectationFailure": false,
"random": true
}
}
9 changes: 7 additions & 2 deletions packages/connect-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"scripts": {
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
"build": "npm run build:cjs && npm run build:esm+types",
"build:cjs": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
"build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types",
"jasmine": "jasmine --config=jasmine.json"
},
"main": "./dist/cjs/index.js",
"type": "module",
Expand All @@ -31,6 +32,10 @@
"peerDependencies": {
"@bufbuild/protobuf": "^1.0.0"
},
"devDependencies": {
"@types/jasmine": "^4.3.1",
"jasmine": "^4.6.0"
},
"files": [
"dist/**"
]
Expand Down
24 changes: 24 additions & 0 deletions packages/connect-node/src/node-universal-header.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2021-2023 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { nodeHeaderToWebHeader } from "./node-universal-header.js";

describe("nodeHeaderToWebHeader", function () {
it("should accept empty node header", function () {
const h = nodeHeaderToWebHeader({});
let numHeaders = 0;
h.forEach(() => numHeaders++);
expect(numHeaders).toBe(0);
});
});
1 change: 1 addition & 0 deletions packages/connect-node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"files": ["src/index.ts"],
"include": ["src/**/*.spec.ts"],
"extends": "../../tsconfig.base.json"
}
10 changes: 5 additions & 5 deletions packages/connect-web-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"scripts": {
"clean": "rm -rf ./dist/esm/*",
"generate": "buf generate",
"build": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm",
"jasmine": "../../node_modules/.bin/jasmine --config=jasmine.json",
"karma": "../../node_modules/.bin/karma start karma.conf.cjs",
"karma-serve": "../../node_modules/.bin/karma start karma.serve.conf.cjs",
"karma-browserstack": "../../node_modules/.bin/karma start karma.browserstack.conf.cjs"
"build": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm",
"jasmine": "jasmine --config=jasmine.json",
"karma": "karma start karma.conf.cjs",
"karma-serve": "karma start karma.serve.conf.cjs",
"karma-browserstack": "karma start karma.browserstack.conf.cjs"
},
"type": "module",
"types": "./dist/types/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"scripts": {
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
"build": "npm run build:cjs && npm run build:esm+types",
"build:cjs": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
"build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
},
"main": "./dist/cjs/index.js",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions packages/connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
"generate": "buf generate src/protocol-grpc/proto",
"build": "npm run build:cjs && npm run build:esm+types",
"build:cjs": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types",
"jasmine": "../../node_modules/.bin/jasmine --config=jasmine.json"
"build:cjs": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs && echo >./dist/cjs/package.json '{\"type\":\"commonjs\"}'",
"build:esm+types": "tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types",
"jasmine": "jasmine --config=jasmine.json"
},
"main": "./dist/cjs/index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/protoc-gen-connect-es/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"scripts": {
"clean": "rm -rf ./dist/cjs/*",
"build": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs"
"build": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs"
},
"preferUnplugged": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/protoc-gen-connect-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"scripts": {
"clean": "rm -rf ./dist/cjs/*",
"build": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs"
"build": "tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs"
},
"preferUnplugged": true,
"dependencies": {
Expand Down

0 comments on commit c18d298

Please sign in to comment.