Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(e2e): add cucumber test runner #711

Merged
merged 17 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/app-cucumber/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<NuxtWelcome />
</div>
</template>
14 changes: 14 additions & 0 deletions examples/app-cucumber/cucumber.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"default": {
"paths": [
"test/acceptance/features/**/*.feature"
],
"import": [
"test/acceptance/**/*.ts"
],
"publish": false,
"format": [
"summary"
]
}
}
4 changes: 4 additions & 0 deletions examples/app-cucumber/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true }
})
23 changes: 23 additions & 0 deletions examples/app-cucumber/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "nuxt-app-cucumber",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"test": "NODE_OPTIONS='--loader ts-node/esm' NODE_ENV=test cucumber-js"
},
"dependencies": {
"nuxt": "^3.9.1",
"vue": "^3.4.7",
"vue-router": "^4.2.5"
},
"devDependencies": {
"@cucumber/cucumber": "^10.2.1",
"@nuxt/test-utils": "latest",
"ts-node": "^10.9.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@tag-home-page

Feature: 🏠 Home Page

Scenario: 🏠 Home Page is displayed
Given the user goes on the home page
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import assert from 'node:assert'
import { Given } from '@cucumber/cucumber'
import { $fetch, createPage } from '@nuxt/test-utils/e2e'

Given(/^the user goes on the home page$/u, async function (): Promise<void> {
// Browser test
const page = await createPage('/')
const text = await page.getByRole('heading', { name: 'Welcome to Nuxt!' }).innerText()
assert.match(text, /Welcome to Nuxt!/)
await page.close()

// SSR test
const html: string = await $fetch('/')
assert.match(html, /<!DOCTYPE html>/)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { fileURLToPath } from 'node:url'
import { setup } from '@nuxt/test-utils/e2e'

await setup({
runner: 'cucumber',
server: true,
rootDir: fileURLToPath(new URL('../../../..', import.meta.url))
})
3 changes: 3 additions & 0 deletions examples/app-cucumber/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"lint": "eslint --ext .vue,.ts,.js,.mjs .",
"lint:fix": "eslint --ext .vue,.ts,.js,.mjs . --fix",
"test:examples": "pnpm -r test",
"test:examples": "pnpm -r test --filter !nuxt-app-cucumber && pnpm -r test --filter nuxt-app-cucumber",
"test:types": "vue-tsc --noEmit",
"test:unit": "vitest test/unit --run",
"prepack": "unbuild",
Expand Down Expand Up @@ -63,6 +63,7 @@
"vitest-environment-nuxt": "^1.0.0"
},
"devDependencies": {
"@cucumber/cucumber": "^10.2.1",
"@jest/globals": "29.7.0",
"@nuxt/devtools": "1.0.8",
"@nuxt/eslint-config": "0.2.0",
Expand Down Expand Up @@ -93,6 +94,7 @@
"vue-tsc": "1.8.27"
},
"peerDependencies": {
"@cucumber/cucumber": "^10.2.1",
"@jest/globals": "^29.5.0",
"@testing-library/vue": "^7.0.0 || ^8.0.1",
"@vitest/ui": "^0.34.6 || ^1.0.0",
Expand All @@ -107,6 +109,9 @@
"vue-router": "^4.0.0"
},
"peerDependenciesMeta": {
"@cucumber/cucumber": {
"optional": true
},
"@testing-library/vue": {
"optional": true
},
Expand Down
Loading
Loading