diff --git a/packages/iceform-next/cypress.config.ts b/packages/iceform-next/cypress.config.ts index 6a44da8..348770f 100644 --- a/packages/iceform-next/cypress.config.ts +++ b/packages/iceform-next/cypress.config.ts @@ -1,26 +1,45 @@ -import { defineConfig } from "cypress"; -import { resolve } from 'path'; +import { defineConfig } from 'cypress'; import { mkdir, rm, writeFile } from 'fs/promises'; export default defineConfig({ e2e: { setupNodeEvents(on, config) { // implement node event listeners here - on('task', { - async resetDb() { - console.log(resolve('../iceform-next-sandbox/.db')); - await rm('../iceform-next-sandbox/.db', { force: true, recursive: true }); - await mkdir('../iceform-next-sandbox/.db'); - await writeFile('../iceform-next-sandbox/.db/notes.jsonl', ''); - return null; - } - }); - }, - }, - component: { - devServer: { - framework: 'next', - bundler: 'webpack', + on('task', { + async 'db:reset'() { + try { + await rm('../iceform-next-sandbox/.db', { + force: true, + recursive: true, + }); + } catch { + // noop + } + + try { + await mkdir('../iceform-next-sandbox/.db'); + await writeFile('../iceform-next-sandbox/.db/notes.jsonl', ''); + return null; + } catch { + // noop + } + + return undefined; + }, + async 'db:shutdown'() { + try { + await rm('../iceform-next-sandbox/.db', { + force: true, + recursive: true, + }); + return null; + } catch { + // noop + } + + return undefined; + }, + }); }, }, }); diff --git a/packages/iceform-next/cypress/e2e/form.cy.ts b/packages/iceform-next/cypress/e2e/form.cy.ts index 5839162..37a7d1f 100644 --- a/packages/iceform-next/cypress/e2e/form.cy.ts +++ b/packages/iceform-next/cypress/e2e/form.cy.ts @@ -1,6 +1,10 @@ describe('form', () => { beforeEach(() => { - cy.task('resetDb'); + cy.task('db:reset'); + }); + + after(() => { + cy.task('db:shutdown'); }); describe('script', () => { diff --git a/packages/iceform-next/package.json b/packages/iceform-next/package.json index d0f90a8..225bbf0 100644 --- a/packages/iceform-next/package.json +++ b/packages/iceform-next/package.json @@ -35,6 +35,7 @@ "react-test-renderer": "^18.2.0", "tslib": "^2.5.0", "typescript": "^4.9.5", + "vite": "^4.4.11", "vitest": "^0.34.1" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e8ef0e0..e0860b3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -87,6 +87,9 @@ importers: typescript: specifier: ^4.9.5 version: 4.9.5 + vite: + specifier: ^4.4.11 + version: 4.4.11(@types/node@18.14.1) vitest: specifier: ^0.34.1 version: 0.34.1(jsdom@21.1.0) @@ -6152,7 +6155,7 @@ packages: mlly: 1.4.2 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.4.9(@types/node@18.14.1) + vite: 4.4.11(@types/node@18.14.1) transitivePeerDependencies: - '@types/node' - less @@ -6164,8 +6167,8 @@ packages: - terser dev: true - /vite@4.4.9(@types/node@18.14.1): - resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} + /vite@4.4.11(@types/node@18.14.1): + resolution: {integrity: sha512-ksNZJlkcU9b0lBwAGZGGaZHCMqHsc8OpgtoYhsQ4/I2v5cnpmmmqe5pM4nv/4Hn6G/2GhTdj0DhZh2e+Er1q5A==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true peerDependencies: @@ -6253,7 +6256,7 @@ packages: strip-literal: 1.3.0 tinybench: 2.5.1 tinypool: 0.7.0 - vite: 4.4.9(@types/node@18.14.1) + vite: 4.4.11(@types/node@18.14.1) vite-node: 0.34.1(@types/node@18.14.1) why-is-node-running: 2.2.2 transitivePeerDependencies: