diff options
author | silverwind <me@silverwind.io> | 2022-10-14 15:36:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-14 21:36:16 +0800 |
commit | c3098076b5264f080fc727d73bfd538916ac02b3 (patch) | |
tree | b6e217e73159deb011e537ac90d82c1edaed15fc /web_src | |
parent | 9dc264a2eebbd30bbff483c26bf27f0406677f77 (diff) | |
download | gitea-c3098076b5264f080fc727d73bfd538916ac02b3.tar.gz gitea-c3098076b5264f080fc727d73bfd538916ac02b3.zip |
Switch from jest to vitest (#21444)
Even if we are not bundling with `vite` yet, we can use `vitest` in
place of Jest which brings a few benefits like not requiring to use
`NODE_OPTIONS` to run and having sane module resolution.
It's possible to also use `jest-extended` with vitest, but I opted to
not do so for now because it brings heavyweight dependencies and it was
trivial to just rewrite the affected matchers to be compatible.
This PR also removes 153 JS dependencies, which is certainly nice.
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/svg.test.js | 6 | ||||
-rw-r--r-- | web_src/js/test/setup.js (renamed from web_src/js/testUtils/jestSetup.js) | 2 | ||||
-rw-r--r-- | web_src/js/testUtils/jestRawLoader.js | 5 | ||||
-rw-r--r-- | web_src/js/utils.test.js | 4 |
4 files changed, 6 insertions, 11 deletions
diff --git a/web_src/js/svg.test.js b/web_src/js/svg.test.js index f1939c3a46..9f2836b667 100644 --- a/web_src/js/svg.test.js +++ b/web_src/js/svg.test.js @@ -1,7 +1,7 @@ import {svg} from './svg.js'; test('svg', () => { - expect(svg('octicon-repo')).toStartWith('<svg'); - expect(svg('octicon-repo', 16)).toInclude('width="16"'); - expect(svg('octicon-repo', 32)).toInclude('width="32"'); + expect(svg('octicon-repo')).toMatch(/^<svg/); + expect(svg('octicon-repo', 16)).toContain('width="16"'); + expect(svg('octicon-repo', 32)).toContain('width="32"'); }); diff --git a/web_src/js/testUtils/jestSetup.js b/web_src/js/test/setup.js index 779be9f0c7..7c208eb0d2 100644 --- a/web_src/js/testUtils/jestSetup.js +++ b/web_src/js/test/setup.js @@ -1,5 +1,5 @@ window.config = { - csrfToken: 'jest-test-csrf-token-123456', + csrfToken: 'test-csrf-token-123456', pageData: {}, i18n: {}, }; diff --git a/web_src/js/testUtils/jestRawLoader.js b/web_src/js/testUtils/jestRawLoader.js deleted file mode 100644 index 15c9f7dc01..0000000000 --- a/web_src/js/testUtils/jestRawLoader.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { // eslint-disable-line import/no-unused-modules - process: (content) => { - return {code: `module.exports = ${JSON.stringify(content)}`}; - }, -}; diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js index 762f29f6fe..b56d80ac7a 100644 --- a/web_src/js/utils.test.js +++ b/web_src/js/utils.test.js @@ -56,8 +56,8 @@ test('joinPaths', () => { }); test('isObject', () => { - expect(isObject({})).toBeTrue(); - expect(isObject([])).toBeFalse(); + expect(isObject({})).toBeTruthy(); + expect(isObject([])).toBeFalsy(); }); test('uniq', () => { |