@semic/testing
TypeScript icon, indicating that this package has built-in type declarations

2.2.11 • Public • Published

@semic/testing

create dev server

import { getDirname } from "@semic/common";
import { createTestServer, initialData } from "@semic/testing";
import { registerInitializer, SqljsInitializer } from "@vendure/testing";
import { config } from "dotenv";
import { SemicAdminPlugin } from "../src/admin.plugin.js";

config();
registerInitializer("sqljs", new SqljsInitializer("__data__"));

const { server } = await createTestServer({
  type: "dev-server",
  metaUrl: import.meta.url,
  overridePlugins: {
    plugins: [
      SemicAdminPlugin.init({
       ...
      }),
    ],
  },
});

await server.init({
  initialData,
  productsCsvPath: getDirname(
    import.meta.url,
    "../../testing/mock-data/products.csv"
  ),
});

create e2e testing server

let server: TestServer;
let shopClient: SimpleGraphQLClient;
let adminClient: SimpleGraphQLClient;
const serverStarted = false;

beforeAll(async () => {
  registerInitializer("sqljs", new SqljsInitializer("__data__"));
  ({ server, adminClient, shopClient } = await createTestServer({
    type: "e2e",
    metaUrl: import.meta.url,
    overridePlugins: {
      plugins: [
        SemicAdminPlugin.init({
          ...
        }),
      ],
    },
  }));

  await server.init({
    initialData,
    productsCsvPath: getDirname(
      import.meta.url,
      "../../testing/mock-data/products.csv"
    ),
  });

  await adminClient.asSuperAdmin();
}, 60000);

Readme

Keywords

none

Package Sidebar

Install

npm i @semic/testing

Weekly Downloads

0

Version

2.2.11

License

MIT

Unpacked Size

495 kB

Total Files

37

Last publish

Collaborators

  • hyperse.net
  • tianyingchun