connected-solid esm upgrade

main
Jackson Morgan 4 months ago
parent 3ecbbe072a
commit 95614b31fb
  1. 2130
      package-lock.json
  2. 3
      package.json
  3. 4
      packages/connected-solid/package.json
  4. 22
      packages/connected-solid/test/Integration.test.ts
  5. 1
      packages/connected-solid/test/LeafRequester.test.ts
  6. 13
      packages/connected-solid/test/RequestBatcher.test.ts
  7. 2
      packages/connected-solid/test/Websocket2023NotificationSubscription.test.ts
  8. 1
      packages/connected-solid/test/guaranteeFetch.test.ts
  9. 1
      packages/connected-solid/test/uriTypes.test.ts
  10. 19
      packages/connected-solid/tsconfig.test.json
  11. 9
      packages/connected-solid/vitest.config.js
  12. 2
      packages/test-solid-server/package.json
  13. 24
      packages/test-solid-server/src/setupTestServer.ts
  14. 2
      packages/test-solid-server/tsconfig.build.json

2130
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -25,6 +25,7 @@
"lerna": "^7.2.0",
"prettier": "3.0.3",
"ts-jest": "^29.3.0",
"typescript": "^5.2.2"
"typescript": "^5.2.2",
"vitest": "^3.1.3"
}
}

@ -18,8 +18,7 @@
"build": "rimraf dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:esm": "tsc --project tsconfig.esm.json",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"test:watch": "jest --watch",
"test": "vitest run --coverage",
"prepublishOnly": "npm run test && npm run build",
"build:ldo": "ldo build --input src/.shapes --output src/.ldo",
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
@ -44,7 +43,6 @@
"@solid-notifications/types": "^0.1.2",
"@solid/community-server": "^7.1.3",
"cross-env": "^7.0.3",
"jest-rdf": "^1.8.0",
"ts-node": "^10.9.1",
"typed-emitter": "^2.1.0",
"typedoc": "^0.25.4",

@ -47,7 +47,7 @@ import {
import { getStorageFromWebId } from "../src/getStorageFromWebId.js";
import type { ResourceInfo } from "@ldo/test-solid-server";
import { createApp, setupServer } from "@ldo/test-solid-server";
import { jest } from "@jest/globals";
import { describe, it, expect, vi, beforeEach } from "vitest";
const ROOT_CONTAINER = "http://localhost:3001/";
const WEB_ID = "http://localhost:3001/example/profile/card#me";
@ -2044,7 +2044,7 @@ describe("Integration", () => {
const resource = solidLdoDataset.getResource(SAMPLE_DATA_URI);
await resource.read();
const spidermanCallback = jest.fn();
const spidermanCallback = vi.fn();
solidLdoDataset.addListener(
[spidermanNode, null, null, null],
spidermanCallback,
@ -2100,13 +2100,13 @@ describe("Integration", () => {
const testContainer = solidLdoDataset.getResource(TEST_CONTAINER_URI);
await resource.read();
const spidermanCallback = jest.fn();
const spidermanCallback = vi.fn();
solidLdoDataset.addListener(
[spidermanNode, null, null, null],
spidermanCallback,
);
const containerCallback = jest.fn();
const containerCallback = vi.fn();
solidLdoDataset.addListener(
[namedNode(TEST_CONTAINER_URI), null, null, null],
containerCallback,
@ -2134,13 +2134,13 @@ describe("Integration", () => {
const testContainer = solidLdoDataset.getResource(TEST_CONTAINER_URI);
await resource.read();
const spidermanCallback = jest.fn();
const spidermanCallback = vi.fn();
solidLdoDataset.addListener(
[spidermanNode, null, null, null],
spidermanCallback,
);
const containerCallback = jest.fn();
const containerCallback = vi.fn();
solidLdoDataset.addListener(
[namedNode(TEST_CONTAINER_URI), null, null, null],
containerCallback,
@ -2168,13 +2168,13 @@ describe("Integration", () => {
const testContainer = solidLdoDataset.getResource(TEST_CONTAINER_URI);
await resource.read();
const spidermanCallback = jest.fn();
const spidermanCallback = vi.fn();
solidLdoDataset.addListener(
[spidermanNode, null, null, null],
spidermanCallback,
);
const containerCallback = jest.fn();
const containerCallback = vi.fn();
solidLdoDataset.addListener(
[namedNode(TEST_CONTAINER_URI), null, null, null],
containerCallback,
@ -2203,7 +2203,7 @@ describe("Integration", () => {
it.skip("returns an error when it cannot subscribe to a notification", async () => {
const resource = solidLdoDataset.getResource(SAMPLE_DATA_URI);
const onError = jest.fn();
const onError = vi.fn();
await s.app.stop();
await resource.subscribeToNotifications({
@ -2215,7 +2215,7 @@ describe("Integration", () => {
it.skip("returns an error when the server doesnt support websockets", async () => {
const resource = solidLdoDataset.getResource(SAMPLE_DATA_URI);
const onError = jest.fn();
const onError = vi.fn();
await s.app.stop();
const disabledWebsocketsApp = await createApp(
@ -2233,7 +2233,7 @@ describe("Integration", () => {
it.skip("attempts to reconnect multiple times before giving up.", async () => {
const resource = solidLdoDataset.getResource(SAMPLE_DATA_URI);
const onError = jest.fn();
const onError = vi.fn();
await s.app.stop();
const disabledWebsocketsApp = await createApp(

@ -4,6 +4,7 @@
// import { createSolidLdoDataset } from "../src/createSolidLdoDataset.js";
// import { LeafRequester } from "../src/requester/LeafRequester.js";
// import { namedNode, quad as createQuad } from "@rdfjs/data-model";
import { describe, it, expect } from "vitest";
describe("Leaf Requester", () => {
it("trivial", () => {

@ -1,7 +1,6 @@
import type { WaitingProcess } from "../src/util/RequestBatcher.js";
import { RequestBatcher } from "../src/util/RequestBatcher.js";
import { jest } from "@jest/globals";
import { describe, it, expect, vi } from "vitest";
describe("RequestBatcher", () => {
type ReadWaitingProcess = WaitingProcess<[string], string>;
@ -12,13 +11,13 @@ describe("RequestBatcher", () => {
await wait(100);
return `Hello ${input}`;
};
const perform1 = jest.fn(perform);
const perform2 = jest.fn(perform);
const perform3 = jest.fn((input: string): Promise<string> => {
const perform1 = vi.fn(perform);
const perform2 = vi.fn(perform);
const perform3 = vi.fn((input: string): Promise<string> => {
expect(requestBatcher.isLoading("read")).toBe(true);
return perform(input);
});
const perform4 = jest.fn(perform);
const perform4 = vi.fn(perform);
const modifyQueue = (queue, currentlyProcessing, input: [string]) => {
const last = queue[queue.length - 1];
@ -97,7 +96,7 @@ describe("RequestBatcher", () => {
const perform = async (_input: string): Promise<string> => {
throw new Error("Test Error");
};
const perform1 = jest.fn(perform);
const perform1 = vi.fn(perform);
expect(() =>
requestBatcher.queueProcess<[string], string>({
name: "read",

@ -1,3 +1,5 @@
import { describe, it, expect } from "vitest";
describe("Websocket Trivial", () => {
it("is trivial", () => {
expect(true).toBe(true);

@ -1,5 +1,6 @@
import { guaranteeFetch } from "../src/util/guaranteeFetch.js";
import crossFetch from "cross-fetch";
import { describe, it, expect } from "vitest";
describe("guaranteeFetch", () => {
it("returns crossfetch when no fetch is provided", () => {

@ -1,4 +1,5 @@
import { isSolidLeafUri } from "../src/util/isSolidUri";
import { describe, it, expect } from "vitest";
describe("isLeafUri", () => {
it("returns true if the given value is a leaf URI", () => {

@ -1,19 +0,0 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"moduleDetection": "force",
"esModuleInterop": true,
"strict": true,
"resolveJsonModule": true,
"allowJs": false,
"isolatedModules": true,
"sourceMap": true,
"outDir": "./dist"
},
"include": [
"src",
"test"
]
}

@ -0,0 +1,9 @@
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
provider: "istanbul",
},
},
});

@ -2,7 +2,9 @@
"name": "@ldo/test-solid-server",
"version": "1.0.0-alpha.9",
"description": "A solid server to be used in jest tests",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
"scripts": {
"build": "tsc --project tsconfig.build.json && npm run copy-configs",
"prepublishOnly": "npm run build",

@ -6,10 +6,17 @@ import type { ResourceInfo } from "./resourceUtils.js";
import { cleanResources, initResources } from "./resourceUtils.js";
import { generateAuthFetch } from "./authFetch.js";
import fs from "fs/promises";
import "jest-rdf";
import {
beforeAll,
afterAll,
beforeEach,
afterEach,
vi,
type MockedFunction,
} from "vitest";
// Use an increased timeout, since the CSS server takes too much setup time.
jest.setTimeout(40_000);
vi.setConfig({ testTimeout: 40_000 });
export function setupServer(
port: number,
@ -18,9 +25,11 @@ export function setupServer(
) {
const data: {
app: App;
fetchMock: jest.Mock<
Promise<Response>,
[input: RequestInfo | URL, init?: RequestInit | undefined]
fetchMock: MockedFunction<
(
input: RequestInfo | URL,
init?: RequestInit | undefined,
) => Promise<Response>
>;
authFetch: typeof fetch;
rootUri: string;
@ -32,9 +41,6 @@ export function setupServer(
let previousNodeEnv: string | undefined;
beforeAll(async () => {
// Remove Jest ID so that community solid server doesn't use the Jest Import
previousJestId = process.env.JEST_WORKER_ID;
previousNodeEnv = process.env.NODE_ENV;
delete process.env.JEST_WORKER_ID;
process.env.NODE_ENV = "other_test";
// Start up the server
data.app = await createApp(port, customConfigPath);
@ -51,7 +57,7 @@ export function setupServer(
});
beforeEach(async () => {
data.fetchMock = jest.fn(data.authFetch);
data.fetchMock = vi.fn(data.authFetch);
// Create a new document called sample.ttl
await initResources(data.rootUri, resourceInfo, data.authFetch);
});

@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"outDir": "./dist"
},

Loading…
Cancel
Save