diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 6849ed4f..00000000 --- a/.babelrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "presets": [ - ["@babel/env"] - ], - "plugins": [ - "@babel/plugin-transform-runtime" - ] -} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..c6c8b362 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintrc.js b/.eslintrc.js index 2b408cf5..0e331129 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,12 +1,26 @@ module.exports = { + parser: 'vue-eslint-parser', + parserOptions: { + parser: '@typescript-eslint/parser', + sourceType: 'module', + }, extends: [ './node_modules/kcd-scripts/eslint.js', - 'plugin:vue/recommended', - 'prettier/vue', + 'plugin:vue/vue3-recommended', + 'plugin:testing-library/vue', + 'prettier', ], - plugins: ['vue'], rules: { 'no-console': 'off', 'import/no-unresolved': 'off', + 'jest/unbound-method': 'off', + + 'testing-library/no-dom-import': 'off', + 'testing-library/prefer-screen-queries': 'off', + 'testing-library/no-manual-cleanup': 'off', + 'testing-library/no-await-sync-events': 'off', + 'testing-library/prefer-user-event': 'off', + 'testing-library/no-node-access': 'off', + 'testing-library/await-fire-event': 'off', }, } diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index d14881f4..e376fd84 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -9,8 +9,7 @@ assignees: '' -**Describe the bug** -A clear and concise description of what the bug is. +**Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** -Steps to reproduce the behavior: +**To Reproduce** Steps to reproduce the behavior: @@ -46,6 +43,7 @@ Steps to reproduce the behavior: Relevant code or config (if any) ```javascript + ``` **Additional context** diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 00000000..cc17d29d --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,84 @@ +name: validate +on: + push: + branches: + [ + '+([0-9])?(.{+([0-9]),x}).x', + 'main', + 'next', + 'next-major', + 'beta', + 'alpha', + '!all-contributors/**', + ] + pull_request: + branches-ignore: ['all-contributors/**'] +jobs: + main: + strategy: + matrix: + node: [14, 16, 18] + runs-on: ubuntu-latest + steps: + - name: ⬇️ Checkout repo + uses: actions/checkout@v3 + + - name: βŽ” Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + + - name: πŸ“₯ Download deps + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + # Needed because @vue/apollo-composable requires @vue/composition-api + # which has a peerDep on Vue 2. + install-command: npm i --legacy-peer-deps + + - name: ▢️ Run validate script + run: npm run validate + + - name: ⬆️ Upload coverage report + uses: codecov/codecov-action@v3 + + release: + needs: main + runs-on: ubuntu-latest + if: + ${{ github.repository == 'testing-library/vue-testing-library' && + contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha', + github.ref) && github.event_name == 'push' }} + steps: + - name: ⬇️ Checkout repo + uses: actions/checkout@v3 + + - name: βŽ” Setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: πŸ“₯ Download deps + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + + - name: πŸ— Run build script + run: npm run build + + - name: πŸš€ Release + uses: cycjimmy/semantic-release-action@v2 + with: + semantic_version: 17 + branches: | + [ + '+([0-9])?(.{+([0-9]),x}).x', + 'main', + 'next', + 'next-major', + {name: 'beta', prerelease: true}, + {name: 'alpha', prerelease: true} + ] + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..43c97e71 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/.prettierrc.js b/.prettierrc.js index b2b58030..4679d9bf 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,5 +1 @@ -module.exports = { - proseWrap: 'always', - semi: false, - singleQuote: true, -} +module.exports = require('kcd-scripts/prettier') diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 017d0c4f..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: false -language: node_js -cache: - directories: - - ~/.npm -notifications: - email: false -node_js: - - '8' - - '10' - - '12' -install: npm install -script: npm run validate -after_success: kcd-scripts travis-after-success -branches: - only: master \ No newline at end of file diff --git a/README.md b/README.md index 3b136d04..4208463c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ height="80" width="80" alt="lizard" - src="https://raw.githubusercontent.com/testing-library/vue-testing-library/master/lizard.png" + src="https://raw.githubusercontent.com/testing-library/vue-testing-library/main/lizard.png" /> @@ -27,13 +27,11 @@
-[![Build Status][build-badge]][build] [![Coverage Status][coverage-badge]][coverage] [![GitHub version][github-badge]][github] [![npm version][npm-badge]][npm] - +[![Discord][discord-badge]][discord] [![MIT License][license-badge]][license] -[![Join the community on Spectrum][spectrum-badge]][spectrum]

Table of Contents

@@ -42,11 +40,16 @@ - [Installation](#installation) -- [A simple example](#a-simple-example) +- [A basic example](#a-basic-example) - [More examples](#more-examples) +- [Guiding Principles](#guiding-principles) - [Docs](#docs) - [Typings](#typings) -- [ESLint](#eslint-support) +- [ESLint support](#eslint-support) +- [Issues](#issues) + - [πŸ› Bugs](#-bugs) + - [πŸ’‘ Feature Requests](#-feature-requests) + - [❓ Questions](#-questions) - [License](#license) - [Contributors](#contributors) @@ -61,25 +64,30 @@ project's `devDependencies`: npm install --save-dev @testing-library/vue ``` -This library has `peerDependencies` listings for `Vue` and -`vue-template-compiler`. +This library has `peerDependencies` listings for `Vue 3` and +`@vue/compiler-sfc`. + +You may also be interested in installing `jest-dom` so you can use [the custom +Jest matchers][jest-dom]. -You may also be interested in installing `jest-dom` so you can use -[the custom Jest matchers](https://github.com/testing-library/jest-dom#readme). +If you're using Vue 2, please install version 5 of the library: -## A simple example +``` +npm install --save-dev @testing-library/vue@^5 +``` + + +## A basic example ```html - diff --git a/src/__tests__/components/Card.vue b/src/__tests__/components/Card.vue index 9174e499..c62ee1b4 100644 --- a/src/__tests__/components/Card.vue +++ b/src/__tests__/components/Card.vue @@ -1,22 +1,6 @@ - - diff --git a/src/__tests__/components/Collapsible.vue b/src/__tests__/components/Collapsible.vue index 33766853..120db8eb 100644 --- a/src/__tests__/components/Collapsible.vue +++ b/src/__tests__/components/Collapsible.vue @@ -15,7 +15,7 @@ export default { } }, methods: { - handleClick(e) { + handleClick(_) { this.displayElement = !this.displayElement }, }, diff --git a/src/__tests__/components/Directive.vue b/src/__tests__/components/Directive.vue new file mode 100644 index 00000000..679cd032 --- /dev/null +++ b/src/__tests__/components/Directive.vue @@ -0,0 +1,15 @@ + + + diff --git a/src/__tests__/components/Form.vue b/src/__tests__/components/Form.vue index 78b83ca9..c3ee7452 100644 --- a/src/__tests__/components/Form.vue +++ b/src/__tests__/components/Form.vue @@ -1,73 +1,70 @@ -