Skip to content

Commit

Permalink
Use vitest globals (#27102) (#27311)
Browse files Browse the repository at this point in the history
Backport #27102 by @silverwind

Enable [globals](https://vitest.dev/config/#globals) in vitest, reducing
the noise in test files.

Co-authored-by: silverwind <me@silverwind.io>
  • Loading branch information
GiteaBot and silverwind committed Sep 27, 2023
1 parent e4cf9d2 commit d74fba8
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins:
- eslint-plugin-regexp
- eslint-plugin-sonarjs
- eslint-plugin-unicorn
- eslint-plugin-vitest-globals
- eslint-plugin-wc

env:
Expand Down Expand Up @@ -45,6 +46,9 @@ overrides:
- files: ["*.config.*"]
rules:
import/no-unused-modules: [0]
- files: ["**/*.test.*", "web_src/js/test/setup.js"]
env:
vitest-globals/env: true
- files: ["web_src/js/modules/fetch.js", "web_src/js/standalone/**/*"]
rules:
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement, SequenceExpression]
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"eslint-plugin-regexp": "1.15.0",
"eslint-plugin-sonarjs": "0.21.0",
"eslint-plugin-unicorn": "48.0.1",
"eslint-plugin-vitest-globals": "1.4.0",
"eslint-plugin-vue": "9.17.0",
"eslint-plugin-vue-scoped-css": "2.5.0",
"eslint-plugin-wc": "2.0.3",
Expand Down
1 change: 1 addition & 0 deletions vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default defineConfig({
open: false,
allowOnly: true,
passWithNoTests: true,
globals: true,
watch: false,
},
plugins: [
Expand Down
1 change: 0 additions & 1 deletion web_src/js/features/common-issue-list.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {test, expect} from 'vitest';
import {parseIssueListQuickGotoLink} from './common-issue-list.js';

test('parseIssueListQuickGotoLink', () => {
Expand Down
1 change: 0 additions & 1 deletion web_src/js/features/repo-code.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {test, expect} from 'vitest';
import {singleAnchorRegex, rangeAnchorRegex} from './repo-code.js';

test('singleAnchorRegex', () => {
Expand Down
1 change: 0 additions & 1 deletion web_src/js/features/repo-findfile.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {describe, expect, test} from 'vitest';
import {strSubMatch, calcMatchedWeight, filterRepoFilesWeighted} from './repo-findfile.js';

describe('Repo Find Files', () => {
Expand Down
1 change: 0 additions & 1 deletion web_src/js/modules/fetch.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {test, expect} from 'vitest';
import {GET, POST, PATCH, PUT, DELETE} from './fetch.js';

// tests here are only to satisfy the linter for unused functions
Expand Down
1 change: 0 additions & 1 deletion web_src/js/modules/toast.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {test, expect} from 'vitest';
import {showInfoToast, showErrorToast, showWarningToast} from './toast.js';

test('showInfoToast', async () => {
Expand Down
1 change: 0 additions & 1 deletion web_src/js/render/ansi.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {expect, test} from 'vitest';
import {renderAnsi} from './ansi.js';

test('renderAnsi', () => {
Expand Down
1 change: 0 additions & 1 deletion web_src/js/svg.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {expect, test} from 'vitest';
import {svg, SvgIcon, svgParseOuterInner} from './svg.js';
import {createApp, h} from 'vue';

Expand Down
1 change: 0 additions & 1 deletion web_src/js/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {expect, test} from 'vitest';
import {
basename, extname, isObject, stripTags, parseIssueHref,
parseUrl, translateMonth, translateDay, blobToDataURI,
Expand Down
1 change: 0 additions & 1 deletion web_src/js/utils/color.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {test, expect} from 'vitest';
import {useLightTextOnBackground} from './color.js';

test('useLightTextOnBackground', () => {
Expand Down
1 change: 0 additions & 1 deletion web_src/js/utils/match.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {test, expect} from 'vitest';
import {matchEmoji, matchMention} from './match.js';

test('matchEmoji', () => {
Expand Down
1 change: 0 additions & 1 deletion web_src/js/utils/url.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {expect, test} from 'vitest';
import {pathEscapeSegments} from './url.js';

test('pathEscapeSegments', () => {
Expand Down

0 comments on commit d74fba8

Please sign in to comment.