Skip to content

Commit 1ca0cd5

Browse files
committed
getting test environments working
1 parent df223f5 commit 1ca0cd5

File tree

15 files changed

+225
-86
lines changed

15 files changed

+225
-86
lines changed

.aegir.cjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
1+
// import { MockServer } from './test/MockServer'
2+
3+
// let mockServer = new MockServer()
4+
require('ts-node').register({
5+
project: 'tsconfig.json',
6+
})
7+
const { MockServer } = require('./test/MockServer')
8+
19
/** @type {import('aegir').PartialOptions} */
210
module.exports = {
11+
docs: {
12+
publish: true,
13+
entryPoint: './'
14+
},
315
tsRepo: true,
416
build: {
517
config: {
618
platform: 'node'
719
},
820
bundlesizeMax: '44KB'
21+
},
22+
test: {
23+
async before () {
24+
25+
},
26+
async beforeEach () {
27+
28+
// mockServer = new MockServer()
29+
await mockServer.start()
30+
},
31+
async afterEach () {
32+
33+
await mockServer.stop()
34+
},
35+
async after () {
36+
37+
}
938
}
1039
}

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ use asdf
33
export PATH=$(npm bin):${PATH}
44
export MOCK_PINNING_SERVER_PORT=3000
55
export MOCK_PINNING_SERVER_SECRET=secret
6+
export DEBUG=1

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ yarn.lock
99
test/ts-use/tsconfig.tsbuildinfo
1010
test/tsconfig.tsbuildinfo
1111
package-lock.json
12+
*.bak
13+
.swc

fixtures.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
// @ts-check
3-
export async function mochaGlobalSetup () {
3+
// export async function mochaGlobalSetup () {
44

5-
}
5+
// }
66

7-
export async function mochaGlobalTeardown () {
7+
// export async function mochaGlobalTeardown () {
88

9-
}
9+
// }

npm-scripts/fix/gen.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
main() {
4+
# Get all generated files
5+
# local FILES
6+
# FILES=()
7+
local SED_BACKUPS=()
8+
9+
# remove openapi-generator's package and tsconfig json files
10+
for PKG_JSON in generated/*/package.json; do
11+
rm $PKG_JSON
12+
done
13+
for TSC_JSON in generated/*/tsconfig.json; do
14+
rm $TSC_JSON
15+
done
16+
17+
for FILES_LIST in $(find generated/*/.openapi-generator/FILES); do
18+
echo FILES_LIST = $FILES_LIST
19+
for FILE in $(cat $FILES_LIST); do
20+
local DIR=$(dirname $(dirname $FILES_LIST))
21+
local FILE_PATH="${DIR}/${FILE}"
22+
echo "FILE=${FILE_PATH}"
23+
24+
if test -e $FILE_PATH; then
25+
# Replace all occurrances of "&lt;" with "<"
26+
# Replace all occurrances of "&gt;" with ">"
27+
sed -i .bak -e 's/&lt\;/\</g' -e 's/&gt\;/\>/g' $FILE_PATH
28+
SED_BACKUPS+=( $FILE_PATH.bak )
29+
fi
30+
done
31+
done
32+
33+
34+
echo "SED_BACKUPS = ${SED_BACKUPS[@]}"
35+
# test build.. if build succeeds, remove backup file.
36+
37+
}
38+
39+
40+
main $@

package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"bugs": {
1313
"url": "https://github.com/ipfs-shipyard/js-pinning-service-http-client/issues"
1414
},
15+
"keywords": [
16+
"dweb",
17+
"ipfs",
18+
"pinning service",
19+
"protocol labs",
20+
"web3"
21+
],
1522
"engines": {
1623
"node": ">=16.0.0",
1724
"npm": ">=7.0.0"
@@ -126,14 +133,17 @@
126133
"scripts": {
127134
"dep-check": "aegir dep-check src/**/*.ts test/**/*.ts generated/**/*.ts",
128135
"fix": "run-s fix:*",
129-
"fix:gen": "./npm-scripts/fix/generated-code.sh",
136+
"fix:gen": "./npm-scripts/fix/gen.sh",
130137
"fix:lint": "aegir lint --fix",
131138
"lint": "run-s lint:*",
132139
"lint:main": "aegir lint",
133-
"lint:project": "check-aegir-project",
140+
"lint:ts": "aegir ts -p check -- -p tsconfig.json --suppress 6133@generated 6192@generated --stats",
141+
"lint-TODO:project": "check-aegir-project # currently broken due to corrupting the repoUrl",
134142
"release": "aegir release",
135143
"postinstall": "./npm-scripts/postinstall.sh",
136144
"build": "aegir build -- -p tsconfig.json --suppress 6133@generated 6192@generated --stats",
145+
"build:main": "aegir build -- -p tsconfig.json --suppress 6133@generated 6192@generated --stats",
146+
"build:docs": "aegir ts docs",
137147
"test": "run-p test:*",
138148
"test:electron": "aegir test --target electron-main",
139149
"test:node": "aegir test --target node --cov && npx nyc report",
@@ -150,18 +160,22 @@
150160
},
151161
"devDependencies": {
152162
"@openapitools/openapi-generator-cli": "^2.4.26",
153-
"@types/collections": "^5.1.2",
163+
"@swc/core": "^1.2.144",
164+
"@swc/helpers": "^0.3.3",
154165
"@types/express": "^4.17.13",
155166
"@types/mocha": "^9.1.0",
156167
"@types/node": "^17.0.16",
157168
"@types/node-fetch": "^3.0.3",
169+
"@types/portscanner": "^2.1.1",
158170
"aegir": "^36.1.3",
159171
"check-aegir-project": "^1.0.3",
160-
"collections": "^5.1.13",
161172
"dotenvrc": "^1.0.1",
162173
"mock-ipfs-pinning-service": "^0.4.0",
163174
"npm-run-all": "^4.1.5",
164175
"openapi-typescript": "^5.1.1",
176+
"portscanner": "^2.2.0",
177+
"regenerator-runtime": "^0.13.9",
178+
"ts-node": "^10.5.0",
165179
"tsc-silent": "^1.2.1"
166180
},
167181
"exports": {

test/MockServer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ export class MockServer {
7777
token: process.env.MOCK_PINNING_SERVER_SECRET
7878
})
7979

80-
return this._service
80+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
81+
return this._service as Application
8182
}
8283

8384
private async server (port = this.port): Promise<Server> {

test/PinsApi.spec.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

test/browser-tests/.gitkeep

Whitespace-only changes.

test/browser.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* eslint-disable no-console */
2+
3+
import clientTests from './isomorphic-tests/client'
4+
import configurationTests from './isomorphic-tests/configuration'
5+
6+
7+
8+
const setup = async () => {
9+
return await new Promise<void>((resolve, reject) => {
10+
void resolve()
11+
})
12+
}
13+
14+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
15+
describe('browser', async (): Promise<void> => {
16+
console.log(fetch)
17+
await configurationTests(setup)
18+
await clientTests(setup)
19+
})

0 commit comments

Comments
 (0)