@prairielearn/express-test-utils 1.0.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @prairielearn/express-test-utils
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d97b97a: Upgrade all JavaScript dependencies
8
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 4f30b7e: Publish as native ESM
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- /// <reference types="node" />
2
- import * as express from 'express';
3
- import { Server } from 'node:http';
1
+ import { type Server } from 'node:http';
2
+ import { type Express } from 'express';
4
3
  export interface WithServerContext {
5
4
  server: Server;
6
5
  port: number;
7
6
  url: string;
8
7
  }
9
- export declare function withServer(app: express.Express, fn: (ctx: WithServerContext) => Promise<void>): Promise<void>;
8
+ export declare function withServer(app: Express, fn: (ctx: WithServerContext) => Promise<void>): Promise<void>;
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withServer = void 0;
4
- async function withServer(app, fn) {
1
+ import {} from 'node:http';
2
+ import {} from 'express';
3
+ export async function withServer(app, fn) {
5
4
  const server = app.listen();
6
5
  await new Promise((resolve, reject) => {
7
6
  server.on('listening', () => resolve());
@@ -18,7 +17,6 @@ async function withServer(app, fn) {
18
17
  server.close();
19
18
  }
20
19
  }
21
- exports.withServer = withServer;
22
20
  function getServerPort(server) {
23
21
  const address = server.address();
24
22
  // istanbul ignore next
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASO,KAAK,UAAU,UAAU,CAC9B,GAAoB,EACpB,EAA6C;IAE7C,MAAM,MAAM,GA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,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,EAAE,CAAC;YACP,MAAM;YACN,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;YAC3B,GAAG,EAAE,oBAAoB,aAAa,CAAC,MAAM,CAAC,EAAE;SACjD,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,MAAc;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAEjC,uBAAuB;IACvB,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAEzD,uBAAuB;IACvB,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAElF,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC","sourcesContent":["import { type Server } from 'node:http';\n\nimport { type Express } from 'express';\n\nexport interface WithServerContext {\n server: Server;\n port: number;\n url: string;\n}\n\nexport async function withServer(app: Express, fn: (ctx: WithServerContext) => Promise<void>) {\n const server = app.listen();\n\n await new Promise<void>((resolve, reject) => {\n server.on('listening', () => resolve());\n server.on('error', (err) => reject(err));\n });\n\n try {\n await fn({\n server,\n port: getServerPort(server),\n url: `http://localhost:${getServerPort(server)}`,\n });\n } finally {\n server.close();\n }\n}\n\nfunction getServerPort(server: Server): number {\n const address = server.address();\n\n // istanbul ignore next\n if (!address) throw new Error('Server is not listening');\n\n // istanbul ignore next\n if (typeof address === 'string') throw new Error('Server is listening on a pipe');\n\n return address.port;\n}\n"]}
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@prairielearn/express-test-utils",
3
- "version": "1.0.1",
4
- "main": "dist/index.js",
3
+ "version": "2.0.1",
4
+ "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/PrairieLearn/PrairieLearn.git",
8
8
  "directory": "packages/express-test-utils"
9
9
  },
10
+ "main": "dist/index.js",
10
11
  "scripts": {
11
12
  "build": "tsc",
12
13
  "dev": "tsc --watch --preserveWatchOutput"
13
14
  },
14
15
  "dependencies": {
15
- "@types/express": "^4.17.21"
16
+ "@types/express": "^4.17.22"
16
17
  }
17
18
  }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
- import * as express from 'express';
2
- import { Server } from 'node:http';
1
+ import { type Server } from 'node:http';
2
+
3
+ import { type Express } from 'express';
3
4
 
4
5
  export interface WithServerContext {
5
6
  server: Server;
@@ -7,10 +8,7 @@ export interface WithServerContext {
7
8
  url: string;
8
9
  }
9
10
 
10
- export async function withServer(
11
- app: express.Express,
12
- fn: (ctx: WithServerContext) => Promise<void>,
13
- ) {
11
+ export async function withServer(app: Express, fn: (ctx: WithServerContext) => Promise<void>) {
14
12
  const server = app.listen();
15
13
 
16
14
  await new Promise<void>((resolve, reject) => {
package/tsconfig.json CHANGED
@@ -4,8 +4,5 @@
4
4
  "outDir": "./dist",
5
5
  "rootDir": "./src",
6
6
  "types": ["node"]
7
- },
8
- "ts-node": {
9
- "transpileOnly": true
10
7
  }
11
8
  }