Skip to content

Commit

Permalink
chore: add reproduction templates and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Nov 6, 2023
1 parent f141b8d commit 2e06fbf
Show file tree
Hide file tree
Showing 29 changed files with 4,144 additions and 352 deletions.
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "\U0001F41E Bug report"
description: Create a report to help us improve Nuxt
labels: ["pending triage"]
body:
- type: markdown
attributes:
value: |
Please carefully read the contribution docs before creating a bug report
👉 https://nuxt.com/docs/community/reporting-bugs
Please use a template below to create a minimal reproduction
👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app
👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/module
- type: textarea
id: bug-env
attributes:
label: Environment
description: You can use `npx nuxi info` to fill this section
placeholder: Environment
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Reproduction
description: Please provide a link to a repo that can reproduce the problem you ran into. A [**minimal reproduction**](https://nuxt.com/docs/community/reporting-bugs#create-a-minimal-reproduction) is required unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided we might close it.
placeholder: Reproduction
validations:
required: true
- type: textarea
id: bug-description
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!
placeholder: Bug description
validations:
required: true
- type: textarea
id: additonal
attributes:
label: Additional context
description: If applicable, add any other context about the problem here
- type: textarea
id: logs
attributes:
label: Logs
description: |
Optional if provided reproduction. Please try not to insert an image but copy paste the log text.
render: shell-script
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
blank_issues_enabled: true
contact_links:
- name: 📚 Nuxt 3 Documentation
url: https://nuxt.com/docs/getting-started/testing
about: Check the documentation for usage with Nuxt 3
- name: 📚 Nuxt 2 Documentation
url: https://v0.test-utils.nuxtjs.org/
about: Check the documentation for usage with Nuxt 2
- name: 💬 Discussions
url: https://github.com/nuxt/test-utils/discussions
about: Use discussions if you have another issue, an idea for improvement or for asking questions.
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "🚀 Feature request"
description: Suggest a feature that will improve Nuxt
labels: ["pending triage"]
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to fill out this feature request!
Please carefully read the contribution docs before suggesting a new feature
👉 https://nuxt.com/docs/community/contribution/#creating-an-issue
- type: textarea
id: feature-description
attributes:
label: Describe the feature
description: A clear and concise description of what you think would be a helpful addition to Nuxt, including the possible use cases and alternatives you have considered. If you have a working prototype or module that implements it, please include a link.
placeholder: Feature description
validations:
required: true
- type: checkboxes
id: additional-info
attributes:
label: Additional information
description: Additional information that helps us decide how to proceed.
options:
- label: Would you be willing to help implement this feature?
- label: Could this feature be implemented as a module?
- type: checkboxes
id: required-info
attributes:
label: Final checks
description: Before submitting, please make sure you do the following
options:
- label: Read the [contribution guide](https://nuxt.com/docs/community/contribution).
required: true
- label: Check existing [discussions](https://github.com/nuxt/nuxt/discussions) and [issues](https://github.com/nuxt/nuxt/issues).
required: true
32 changes: 32 additions & 0 deletions .github/reproduire/needs-reproduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Would you be able to provide a [reproduction](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction)? 🙏

<details>
<summary>More info</summary>

### Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

### What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

### How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app
👉 https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/module

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction).

You might also find these other articles interesting and/or helpful:

- [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required)
- [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve)

</details>
24 changes: 24 additions & 0 deletions .github/workflows/reproduction-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Close incomplete issues
on:
workflow_dispatch:
schedule:
- cron: '30 1 * * *' # run every day

permissions:
issues: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@1160a2240286f5da8ec72b1c0816ce2481aabf84 # v8.0.0
with:
days-before-stale: -1 # Issues and PR will never be flagged stale automatically.
stale-issue-label: 'needs reproduction' # Label that flags an issue as stale.
only-labels: 'needs reproduction' # Only process these issues
days-before-issue-close: 7
ignore-updates: true
remove-stale-when-updated: false
close-issue-message: This issue was closed because it was open for 7 days without a reproduction.
close-issue-label: closed-by-bot
operations-per-run: 300 #default 30
16 changes: 16 additions & 0 deletions .github/workflows/reproduction.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Reproduire
on:
issues:
types: [labeled]

permissions:
issues: write

jobs:
reproduire:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: Hebilicious/reproduire@4b686ae9cbb72dad60f001d278b6e3b2ce40a9ac # v0.0.9-mp
with:
label: needs reproduction
5 changes: 5 additions & 0 deletions examples/app/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<NuxtWelcome />
</div>
</template>
4 changes: 4 additions & 0 deletions examples/app/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/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"test": "vitest run"
},
"dependencies": {
"nuxt": "^3.8.0",
"vue": "^3.3.7",
"vue-router": "^4.2.5"
},
"devDependencies": {
"@nuxt/test-utils": "latest",
"happy-dom": "^12.10.3",
"nuxt-vitest": "^0.11.2"
}
}
3 changes: 3 additions & 0 deletions examples/app/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
16 changes: 16 additions & 0 deletions examples/app/test/app.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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)),
})

describe('app', async () => {
it('runs a test', async () => {
const html = await $fetch('/')
expect(html.slice(0, 15)).toMatchInlineSnapshot(`
"<!DOCTYPE html>"
`)
})
})
12 changes: 12 additions & 0 deletions examples/app/test/app.nuxt.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { describe, expect, it } from 'vitest'

describe('my test', () => {
// ... test with Nuxt environment!
it('works', () => {
expect(Object.keys(useAppConfig())).toMatchInlineSnapshot(`
[
"nuxt",
]
`)
})
})
3 changes: 3 additions & 0 deletions examples/app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
5 changes: 5 additions & 0 deletions examples/app/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineVitestConfig } from 'nuxt-vitest/config'

export default defineVitestConfig({
// any custom vitest config you require
})
40 changes: 40 additions & 0 deletions examples/module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"private": true,
"name": "my-module",
"version": "1.0.0",
"description": "My new Nuxt module",
"repository": "your-org/my-module",
"license": "MIT",
"type": "module",
"exports": {
".": {
"types": "./dist/types.d.ts",
"import": "./dist/module.mjs",
"require": "./dist/module.cjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"files": [
"dist"
],
"scripts": {
"prepack": "nuxt-module-build build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
"test": "vitest run",
"test:watch": "vitest watch"
},
"dependencies": {
"@nuxt/kit": "^3.8.0"
},
"devDependencies": {
"@nuxt/module-builder": "^0.5.2",
"@nuxt/schema": "^3.8.0",
"@nuxt/test-utils": "latest",
"changelogen": "^0.5.5",
"nuxt": "^3.8.0",
"vitest": "0.33.0"
}
}
8 changes: 8 additions & 0 deletions examples/module/playground/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<div>
Nuxt module playground!
</div>
</template>

<script setup>
</script>
5 changes: 5 additions & 0 deletions examples/module/playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default defineNuxtConfig({
modules: ['../src/module'],
myModule: {},
devtools: { enabled: true }
})
13 changes: 13 additions & 0 deletions examples/module/playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"private": true,
"name": "my-module-playground",
"type": "module",
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"generate": "nuxi generate"
},
"devDependencies": {
"nuxt": "^3.8.0"
}
}
3 changes: 3 additions & 0 deletions examples/module/playground/server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../.nuxt/tsconfig.server.json"
}
3 changes: 3 additions & 0 deletions examples/module/playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
19 changes: 19 additions & 0 deletions examples/module/src/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit'

// Module options TypeScript interface definition
export interface ModuleOptions {}

export default defineNuxtModule<ModuleOptions>({
meta: {
name: 'my-module',
configKey: 'myModule'
},
// Default configuration options of the Nuxt module
defaults: {},
setup (_options, _nuxt) {
const resolver = createResolver(import.meta.url)

// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
addPlugin(resolver.resolve('./runtime/plugin'))
}
})
5 changes: 5 additions & 0 deletions examples/module/src/runtime/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { defineNuxtPlugin } from '#app'

export default defineNuxtPlugin((_nuxtApp) => {
console.log('Plugin injected by my-module!')
})
15 changes: 15 additions & 0 deletions examples/module/test/basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
import { $fetch, setup } from '@nuxt/test-utils'

describe('ssr', async () => {
await setup({
rootDir: fileURLToPath(new URL('./fixtures/basic', import.meta.url)),
})

it('renders the index page', async () => {
// Get response to a server-rendered page with `$fetch`.
const html = await $fetch('/')
expect(html).toContain('<div>basic</div>')
})
})
6 changes: 6 additions & 0 deletions examples/module/test/fixtures/basic/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<div>basic</div>
</template>

<script setup>
</script>
7 changes: 7 additions & 0 deletions examples/module/test/fixtures/basic/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import MyModule from '../../../src/module'

export default defineNuxtConfig({
modules: [
MyModule
]
})
5 changes: 5 additions & 0 deletions examples/module/test/fixtures/basic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"private": true,
"name": "basic",
"type": "module"
}
3 changes: 3 additions & 0 deletions examples/module/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
Loading

0 comments on commit 2e06fbf

Please sign in to comment.