-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
505c1a6
commit 41e62b0
Showing
10 changed files
with
71 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
import type { Config } from 'jest' | ||
|
||
import type {Config} from "jest" | ||
|
||
export default { | ||
extensionsToTreatAsEsm: ['.ts'], | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
} satisfies Config | ||
preset: 'ts-jest/presets/default-esm', // or other ESM presets | ||
moduleNameMapper: { | ||
'^(\\.{1,2}/.*)\\.js$': '$1', | ||
}, | ||
transform: { | ||
'^.+\\.tsx?$': [ | ||
'ts-jest', | ||
{ | ||
useESM: true, | ||
}, | ||
], | ||
}, | ||
} satisfies Config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { createPage, setup } from '@nuxt/test-utils' | ||
import { describe, expect, it } from 'vitest' | ||
import { fileURLToPath } from "node:url"; | ||
import { createPage, setup } from "@nuxt/test-utils"; | ||
|
||
await setup({ | ||
rootDir: fileURLToPath(new URL('../', import.meta.url)), | ||
rootDir: fileURLToPath(new URL("../", import.meta.url)), | ||
browser: true, | ||
runner: 'jest', | ||
}) | ||
runner: "jest", | ||
}); | ||
|
||
describe('browser', async () => { | ||
it('runs a test', async () => { | ||
const page = await createPage('/') | ||
expect(page.getByRole('heading').innerText()).toContain('Welcome to Nuxt!') | ||
}) | ||
}) | ||
describe("browser", () => { | ||
it("runs a test", async () => { | ||
const page = await createPage("/"); | ||
const text = await page.getByRole("heading",{ name: 'Welcome to Nuxt!' }).innerText() | ||
await expect(text).toContain( | ||
"Welcome to Nuxt!" | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { $fetch, setup } from '@nuxt/test-utils' | ||
import { describe, expect, it } from 'vitest' | ||
import { fileURLToPath } from "node:url"; | ||
import { $fetch, setup } from "@nuxt/test-utils"; | ||
|
||
await setup({ | ||
rootDir: fileURLToPath(new URL('../', import.meta.url)), | ||
rootDir: fileURLToPath(new URL("../", import.meta.url)), | ||
dev: true, | ||
runner: 'jest' | ||
}) | ||
runner: "jest", | ||
}); | ||
|
||
describe('server (dev)', async () => { | ||
it('runs a test', async () => { | ||
const html = await $fetch('/') | ||
expect(html.slice(0, 15)).toMatchInlineSnapshot(` | ||
"<!DOCTYPE html>" | ||
`) | ||
}) | ||
}) | ||
describe("server (dev)", () => { | ||
it("runs a test", async () => { | ||
const html = await $fetch("/"); | ||
expect(html.slice(0, 15)).toMatchInlineSnapshot(`"<!DOCTYPE html>"`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { $fetch, setup } from '@nuxt/test-utils' | ||
import { describe, expect, it } from 'vitest' | ||
|
||
// await setup({ | ||
// rootDir: fileURLToPath(new URL('../', import.meta.url)), | ||
// runner: 'jest' | ||
// }) | ||
describe('app', async () => { | ||
it('runs a test', async () => { | ||
expect(true).toBe(true) | ||
// const html = await $fetch('/') | ||
// expect(html.slice(0, 15)).toMatchInlineSnapshot(` | ||
// "<!DOCTYPE html>" | ||
// `) | ||
}) | ||
await setup({ | ||
rootDir: fileURLToPath(new URL('../', import.meta.url)), | ||
runner: 'jest' | ||
}) | ||
|
||
describe("app",()=>{ | ||
it("runs a test",async ()=>{ | ||
const html = await $fetch('/') | ||
expect(html.slice(0, 15)).toMatchInlineSnapshot(`"<!DOCTYPE html>"`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
{ | ||
"extends": "./.nuxt/tsconfig.json", | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
// "lib": ["ES2021"], | ||
"module": "ESNext", | ||
"esModuleInterop": true, | ||
"moduleResolution": "Bundler", | ||
"verbatimModuleSyntax": false, | ||
"moduleResolution": "Bundler" | ||
"target": "ESNext", | ||
"types": ["node", "jest"], | ||
"typeRoots": ["node_modules/@types"], | ||
"resolveJsonModule": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,5 +77,6 @@ | |
}, | ||
"engines": { | ||
"node": "^14.18.0 || >=16.10.0" | ||
} | ||
}, | ||
"packageManager": "pnpm@8.10.2" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters