[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

test: standardising internal test (#5600)

authored by

Vladimir and committed by
GitHub
(Apr 26, 2024, 3:43 PM +0200) 7c993e94 d7fa5cde

+5191 -6600
+1 -1
.gitignore
··· 27 27 docs/public/sponsors 28 28 .eslintcache 29 29 docs/.vitepress/cache/ 30 - !test/cwd/**/.cache 30 + !test/cli/fixtures/dotted-files/**/.cache
+2 -2
eslint.config.js
··· 14 14 '**/*.timestamp-*', 15 15 'test/core/src/self', 16 16 'test/cache/cache/.vitest-base/results.json', 17 - 'test/wasm-modules/src/wasm-bindgen-no-cyclic', 17 + 'test/core/src/wasm/wasm-bindgen-no-cyclic', 18 18 'test/workspaces/results.json', 19 19 'test/workspaces-browser/results.json', 20 20 'test/reporters/fixtures/with-syntax-error.test.js', ··· 100 100 files: [ 101 101 `docs/${GLOB_SRC}`, 102 102 `packages/web-worker/${GLOB_SRC}`, 103 - `test/web-worker/${GLOB_SRC}`, 103 + `test/core/${GLOB_SRC}`, 104 104 ], 105 105 rules: { 106 106 'no-restricted-globals': 'off',
+3 -6
package.json
··· 24 24 "lint:fix": "nr lint --fix", 25 25 "publish-ci": "tsx scripts/publish-ci.ts", 26 26 "release": "bumpp package.json packages/*/package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release", 27 - "test": "vitest --api -r test/core", 28 - "test:run": "vitest run -r test/core", 29 - "test:all": "CI=true pnpm -r --stream run test --allowOnly", 30 - "test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-browser --filter !test-esm --filter !test-browser run test --allowOnly", 31 - "test:ci:vm-threads": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-coverage --filter !test-single-thread --filter !test-browser --filter !test-esm --filter !test-network-imports --filter !test-browser --filter !example-react-testing-lib-msw run test --allowOnly --pool vmThreads", 32 - "test:ci:no-threads": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-vm-threads --filter !test-coverage --filter !test-watch --filter !test-bail --filter !test-esm --filter !test-browser run test --allowOnly --pool forks", 27 + "test": "pnpm --filter test-core test:threads", 28 + "test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/test-*' --filter !test-browser run test", 29 + "test:examples": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/example-*' run test", 33 30 "typecheck": "tsc -p tsconfig.check.json --noEmit", 34 31 "typecheck:why": "tsc -p tsconfig.check.json --noEmit --explainFiles > explainTypes.txt", 35 32 "ui:build": "vite build packages/ui",
+69 -707
pnpm-lock.yaml
··· 1520 1520 specifier: workspace:* 1521 1521 version: link:../runner 1522 1522 1523 - test/bail: 1524 - devDependencies: 1525 - '@vitest/browser': 1526 - specifier: workspace:* 1527 - version: link:../../packages/browser 1528 - vite: 1529 - specifier: ^5.2.6 1530 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) 1531 - vitest: 1532 - specifier: workspace:* 1533 - version: link:../../packages/vitest 1534 - webdriverio: 1535 - specifier: latest 1536 - version: 8.6.3(typescript@5.2.2) 1537 - 1538 - test/base: 1539 - devDependencies: 1540 - vitest: 1541 - specifier: workspace:* 1542 - version: link:../../packages/vitest 1543 - 1544 1523 test/benchmark: 1545 1524 devDependencies: 1546 1525 vitest: ··· 1574 1553 specifier: ^8.32.2 1575 1554 version: 8.32.2(typescript@5.2.2) 1576 1555 1577 - test/cache: 1578 - devDependencies: 1579 - vitest: 1580 - specifier: workspace:* 1581 - version: link:../../packages/vitest 1582 - 1583 - test/changed: 1584 - devDependencies: 1585 - vitest: 1586 - specifier: workspace:* 1587 - version: link:../../packages/vitest 1588 - 1589 - test/cjs: 1590 - devDependencies: 1591 - '@types/fs-extra': 1592 - specifier: ^9.0.13 1593 - version: 9.0.13 1594 - '@types/lodash': 1595 - specifier: ^4.14.201 1596 - version: 4.14.201 1597 - '@types/prettier': 1598 - specifier: ^2.6.1 1599 - version: 2.7.0 1600 - fs-extra: 1601 - specifier: ^10.1.0 1602 - version: 10.1.0 1603 - givens: 1604 - specifier: 1.3.9 1605 - version: 1.3.9 1606 - history: 1607 - specifier: ^5.3.0 1608 - version: 5.3.0 1609 - lodash: 1610 - specifier: ^4.17.21 1611 - version: 4.17.21 1612 - prettier: 1613 - specifier: ^2.6.2 1614 - version: 2.7.1 1615 - temp-dir: 1616 - specifier: ^2.0.0 1617 - version: 2.0.0 1618 - vitest: 1619 - specifier: workspace:* 1620 - version: link:../../packages/vitest 1621 - 1622 1556 test/cli: 1623 1557 devDependencies: 1558 + '@types/debug': 1559 + specifier: ^4.1.12 1560 + version: 4.1.12 1561 + '@types/ws': 1562 + specifier: ^8.5.9 1563 + version: 8.5.9 1564 + '@vitejs/plugin-basic-ssl': 1565 + specifier: ^1.0.2 1566 + version: 1.0.2(vite@5.2.6) 1567 + '@vitest/runner': 1568 + specifier: workspace:^ 1569 + version: link:../../packages/runner 1570 + debug: 1571 + specifier: ^4.3.4 1572 + version: 4.3.4(supports-color@8.1.1) 1573 + execa: 1574 + specifier: ^8.0.1 1575 + version: 8.0.1 1624 1576 vite: 1625 1577 specifier: ^5.2.6 1626 1578 version: 5.2.6(@types/node@20.11.5)(less@4.1.3) 1627 1579 vitest: 1628 1580 specifier: workspace:* 1629 1581 version: link:../../packages/vitest 1582 + ws: 1583 + specifier: ^8.14.2 1584 + version: 8.16.0 1630 1585 1631 1586 test/config: 1632 1587 devDependencies: ··· 1648 1603 1649 1604 test/core: 1650 1605 devDependencies: 1606 + '@types/debug': 1607 + specifier: ^4.1.12 1608 + version: 4.1.12 1651 1609 '@vitest/expect': 1652 1610 specifier: workspace:* 1653 1611 version: link:../../packages/expect 1654 1612 '@vitest/runner': 1655 1613 specifier: workspace:* 1656 1614 version: link:../../packages/runner 1615 + '@vitest/test-dep1': 1616 + specifier: file:./deps/dep1 1617 + version: file:test/core/deps/dep1 1618 + '@vitest/test-dep2': 1619 + specifier: file:./deps/dep2 1620 + version: file:test/core/deps/dep2 1657 1621 '@vitest/utils': 1658 1622 specifier: workspace:* 1659 1623 version: link:../../packages/utils 1624 + '@vitest/web-worker': 1625 + specifier: workspace:^ 1626 + version: link:../../packages/web-worker 1627 + debug: 1628 + specifier: ^4.3.4 1629 + version: 4.3.4(supports-color@8.1.1) 1660 1630 strip-ansi: 1661 1631 specifier: ^7.1.0 1662 1632 version: 7.1.0 ··· 1669 1639 vitest: 1670 1640 specifier: workspace:* 1671 1641 version: link:../../packages/vitest 1642 + vitest-environment-custom: 1643 + specifier: file:./vitest-environment-custom 1644 + version: file:test/core/vitest-environment-custom 1672 1645 1673 1646 test/coverage-test: 1674 1647 devDependencies: ··· 1724 1697 specifier: latest 1725 1698 version: 8.6.3(typescript@5.2.2) 1726 1699 1727 - test/css: 1728 - devDependencies: 1729 - jsdom: 1730 - specifier: ^20.0.0 1731 - version: 20.0.0 1732 - vitest: 1733 - specifier: workspace:* 1734 - version: link:../../packages/vitest 1735 - 1736 - test/cwd: 1737 - devDependencies: 1738 - vitest: 1739 - specifier: workspace:* 1740 - version: link:../../packages/vitest 1741 - 1742 - test/edge-runtime: 1743 - devDependencies: 1744 - '@edge-runtime/vm': 1745 - specifier: 1.1.0-beta.26 1746 - version: 1.1.0-beta.26 1747 - '@vitest/web-worker': 1748 - specifier: workspace:* 1749 - version: link:../../packages/web-worker 1750 - vitest: 1751 - specifier: workspace:* 1752 - version: link:../../packages/vitest 1753 - 1754 - test/empty-test: 1755 - devDependencies: 1756 - vitest: 1757 - specifier: workspace:* 1758 - version: link:../../packages/vitest 1759 - 1760 - test/env-custom: 1761 - devDependencies: 1762 - '@types/debug': 1763 - specifier: ^4.1.12 1764 - version: 4.1.12 1765 - debug: 1766 - specifier: ^4.3.4 1767 - version: 4.3.4(supports-color@8.1.1) 1768 - vitest: 1769 - specifier: workspace:* 1770 - version: link:../../packages/vitest 1771 - vitest-environment-custom: 1772 - specifier: file:./vitest-environment-custom 1773 - version: file:test/env-custom/vitest-environment-custom 1774 - 1775 - test/env-custom-file: 1776 - devDependencies: 1777 - '@types/debug': 1778 - specifier: ^4.1.12 1779 - version: 4.1.12 1780 - debug: 1781 - specifier: ^4.3.4 1782 - version: 4.3.4(supports-color@8.1.1) 1783 - vitest: 1784 - specifier: workspace:* 1785 - version: link:../../packages/vitest 1786 - 1787 - test/env-glob: 1788 - devDependencies: 1789 - vitest: 1790 - specifier: workspace:* 1791 - version: link:../../packages/vitest 1792 - 1793 - test/env-mixed: 1794 - devDependencies: 1795 - happy-dom: 1796 - specifier: latest 1797 - version: 8.9.0 1798 - vite: 1799 - specifier: ^5.2.6 1800 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) 1801 - vitest: 1802 - specifier: workspace:* 1803 - version: link:../../packages/vitest 1804 - 1805 - test/esm: 1806 - dependencies: 1807 - css-what: 1808 - specifier: 6.1.0 1809 - version: 6.1.0 1810 - tslib: 1811 - specifier: 2.4.0 1812 - version: 2.4.0 1813 - devDependencies: 1814 - vitest: 1815 - specifier: workspace:* 1816 - version: link:../../packages/vitest 1817 - 1818 - test/failing: 1819 - devDependencies: 1820 - '@vitest/runner': 1821 - specifier: workspace:* 1822 - version: link:../../packages/runner 1823 - vitest: 1824 - specifier: workspace:* 1825 - version: link:../../packages/vitest 1826 - 1827 - test/fails: 1828 - devDependencies: 1829 - '@vitest/coverage-istanbul': 1830 - specifier: workspace:* 1831 - version: link:../../packages/coverage-istanbul 1832 - jsdom: 1833 - specifier: ^21.0.0 1834 - version: 21.0.0 1835 - vitest: 1836 - specifier: workspace:* 1837 - version: link:../../packages/vitest 1838 - 1839 - test/filters: 1840 - devDependencies: 1841 - vite: 1842 - specifier: ^5.2.6 1843 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) 1844 - vitest: 1845 - specifier: workspace:* 1846 - version: link:../../packages/vitest 1847 - 1848 1700 test/global-setup: 1849 - devDependencies: 1850 - vitest: 1851 - specifier: workspace:* 1852 - version: link:../../packages/vitest 1853 - 1854 - test/global-setup-fail: 1855 - devDependencies: 1856 - vitest: 1857 - specifier: workspace:* 1858 - version: link:../../packages/vitest 1859 - 1860 - test/import-meta: 1861 - devDependencies: 1862 - vitest: 1863 - specifier: workspace:* 1864 - version: link:../../packages/vitest 1865 - 1866 - test/inspect: 1867 - devDependencies: 1868 - vite: 1869 - specifier: ^5.2.6 1870 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) 1871 - vitest: 1872 - specifier: workspace:* 1873 - version: link:../../packages/vitest 1874 - ws: 1875 - specifier: ^8.14.2 1876 - version: 8.14.2 1877 - 1878 - test/mixed-pools: 1879 - devDependencies: 1880 - vitest: 1881 - specifier: workspace:* 1882 - version: link:../../packages/vitest 1883 - 1884 - test/network-imports: 1885 1701 devDependencies: 1886 1702 vitest: 1887 1703 specifier: workspace:* ··· 1892 1708 '@vitest/test-dep-url': 1893 1709 specifier: file:./dep-url 1894 1710 version: file:test/optimize-deps/dep-url 1895 - vitest: 1896 - specifier: workspace:* 1897 - version: link:../../packages/vitest 1898 - 1899 - test/path-resolution: 1900 - devDependencies: 1901 - '@edge-runtime/vm': 1902 - specifier: 1.1.0-beta.26 1903 - version: 1.1.0-beta.26 1904 - '@vitest/test-path-resolution-target': 1905 - specifier: workspace:* 1906 - version: link:../path-resolution-target 1907 - '@vitest/web-worker': 1908 - specifier: workspace:* 1909 - version: link:../../packages/web-worker 1910 - vitest: 1911 - specifier: workspace:* 1912 - version: link:../../packages/vitest 1913 - 1914 - test/path-resolution-target: {} 1915 - 1916 - test/public-api: 1917 - devDependencies: 1918 - '@vitest/browser': 1919 - specifier: workspace:* 1920 - version: link:../../packages/browser 1921 1711 vitest: 1922 1712 specifier: workspace:* 1923 1713 version: link:../../packages/vitest ··· 1940 1730 specifier: 0.4.1 1941 1731 version: 0.4.1(vitest@packages+vitest) 1942 1732 1943 - test/resolve: 1944 - devDependencies: 1945 - happy-dom: 1946 - specifier: ^12.10.3 1947 - version: 12.10.3 1948 - vitest: 1949 - specifier: workspace:* 1950 - version: link:../../packages/vitest 1951 - 1952 - test/restricted: 1953 - devDependencies: 1954 - jsdom: 1955 - specifier: ^22.1.0 1956 - version: 22.1.0 1957 - vitest: 1958 - specifier: workspace:* 1959 - version: link:../../packages/vitest 1960 - 1961 - test/run: 1962 - devDependencies: 1963 - '@vitest/runner': 1964 - specifier: workspace:* 1965 - version: link:../../packages/runner 1966 - execa: 1967 - specifier: ^7.1.1 1968 - version: 7.1.1 1969 - vite: 1970 - specifier: ^5.2.6 1971 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) 1972 - vitest: 1973 - specifier: workspace:* 1974 - version: link:../../packages/vitest 1975 - 1976 - test/run-once: 1977 - devDependencies: 1978 - vitest: 1979 - specifier: workspace:* 1980 - version: link:../../packages/vitest 1981 - 1982 - test/setup: 1983 - devDependencies: 1984 - vitest: 1985 - specifier: workspace:* 1986 - version: link:../../packages/vitest 1987 - 1988 - test/shard: 1989 - devDependencies: 1990 - vitest: 1991 - specifier: workspace:* 1992 - version: link:../../packages/vitest 1993 - 1994 - test/single-thread: 1995 - devDependencies: 1996 - vitest: 1997 - specifier: workspace:* 1998 - version: link:../../packages/vitest 1999 - 2000 1733 test/snapshots: 2001 1734 dependencies: 2002 - vitest: 2003 - specifier: workspace:* 2004 - version: link:../../packages/vitest 2005 - 2006 - test/stacktraces: 2007 - devDependencies: 2008 1735 vitest: 2009 1736 specifier: workspace:* 2010 1737 version: link:../../packages/vitest ··· 2055 1782 specifier: workspace:* 2056 1783 version: link:../../packages/vitest 2057 1784 2058 - test/utils: 2059 - devDependencies: 2060 - '@vitest/utils': 2061 - specifier: workspace:* 2062 - version: link:../../packages/utils 2063 - vitest: 2064 - specifier: workspace:* 2065 - version: link:../../packages/vitest 2066 - 2067 - test/vite-config: 2068 - devDependencies: 2069 - pathe: 2070 - specifier: ^1.1.0 2071 - version: 1.1.0 2072 - vitest: 2073 - specifier: workspace:* 2074 - version: link:../../packages/vitest 2075 - 2076 1785 test/vite-node: 2077 1786 devDependencies: 2078 1787 '@types/inquirer': 2079 1788 specifier: ^9.0.3 2080 1789 version: 9.0.3 2081 - '@vitest/test-dep1': 2082 - specifier: file:./deps/dep1 2083 - version: file:test/vite-node/deps/dep1 2084 - '@vitest/test-dep2': 2085 - specifier: file:./deps/dep2 2086 - version: file:test/vite-node/deps/dep2 2087 1790 execa: 2088 1791 specifier: ^6.1.0 2089 1792 version: 6.1.0 ··· 2093 1796 vite-node: 2094 1797 specifier: workspace:* 2095 1798 version: link:../../packages/vite-node 2096 - vitest: 2097 - specifier: workspace:* 2098 - version: link:../../packages/vitest 2099 - 2100 - test/vm-threads: 2101 - devDependencies: 2102 - jsdom: 2103 - specifier: latest 2104 - version: 24.0.0 2105 - vitest: 2106 - specifier: workspace:* 2107 - version: link:../../packages/vitest 2108 - 2109 - test/wasm-modules: 2110 - devDependencies: 2111 1799 vitest: 2112 1800 specifier: workspace:* 2113 1801 version: link:../../packages/vitest ··· 2126 1814 webdriverio: 2127 1815 specifier: latest 2128 1816 version: 8.6.3(typescript@5.2.2) 2129 - 2130 - test/web-worker: 2131 - devDependencies: 2132 - '@vitest/web-worker': 2133 - specifier: workspace:* 2134 - version: link:../../packages/web-worker 2135 - vitest: 2136 - specifier: workspace:* 2137 - version: link:../../packages/vitest 2138 1817 2139 1818 test/workspaces: 2140 1819 devDependencies: ··· 2159 1838 '@vitest/browser': 2160 1839 specifier: workspace:^ 2161 1840 version: link:../../packages/browser 2162 - vitest: 2163 - specifier: workspace:* 2164 - version: link:../../packages/vitest 2165 - 2166 - test/ws-api: 2167 - devDependencies: 2168 - '@vitejs/plugin-basic-ssl': 2169 - specifier: ^1.0.2 2170 - version: 1.0.2(vite@5.2.6) 2171 1841 vitest: 2172 1842 specifier: workspace:* 2173 1843 version: link:../../packages/vitest ··· 5880 5550 engines: {node: '>=6.9.0'} 5881 5551 dependencies: 5882 5552 regenerator-runtime: 0.14.0 5553 + dev: true 5883 5554 5884 5555 /@babel/runtime@7.24.4: 5885 5556 resolution: {integrity: sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==} ··· 6162 5833 - '@algolia/client-search' 6163 5834 dev: true 6164 5835 6165 - /@edge-runtime/primitives@1.1.0-beta.31: 6166 - resolution: {integrity: sha512-OO1x32aJoxgME1k77RVxVNsazs5NY/SNwYEN8ptlZ6DKUXn0eesXftDsmlypX/OU0ZeJc61/xNVUuoeyDGJDVA==} 6167 - dev: true 6168 - 6169 5836 /@edge-runtime/primitives@4.0.6: 6170 5837 resolution: {integrity: sha512-Ahv7SdVJiFryuauSmubY4bVYvVWsf2h/n67TRRT5ERs6eK90xyeCB3hmn1ExTqaZtxO0Q9QTbEUXVxz6o4iSzw==} 6171 5838 engines: {node: '>=16'} 6172 - dev: true 6173 - 6174 - /@edge-runtime/vm@1.1.0-beta.26: 6175 - resolution: {integrity: sha512-hxWtmuO13zgNkM3zHvRENfMeavM+PAKSoHhvzt+sHjSothxGlA06XXN38t/NT6LD4ND8p8FmPJ70+fTptL4a/A==} 6176 - dependencies: 6177 - '@edge-runtime/primitives': 1.1.0-beta.31 6178 5839 dev: true 6179 5840 6180 5841 /@edge-runtime/vm@3.1.8: ··· 6192 5853 '@babel/core': 7.24.4 6193 5854 '@babel/helper-module-imports': 7.22.5 6194 5855 '@babel/plugin-syntax-jsx': 7.18.6(@babel/core@7.24.4) 6195 - '@babel/runtime': 7.23.2 5856 + '@babel/runtime': 7.24.4 6196 5857 '@emotion/hash': 0.9.0 6197 5858 '@emotion/memoize': 0.8.0 6198 5859 '@emotion/serialize': 1.1.0 ··· 7770 7431 '@types/react': 7771 7432 optional: true 7772 7433 dependencies: 7773 - '@babel/runtime': 7.23.2 7434 + '@babel/runtime': 7.24.4 7774 7435 '@emotion/is-prop-valid': 1.2.0 7775 7436 '@mui/types': 7.2.0(@types/react@18.2.37) 7776 7437 '@mui/utils': 5.10.3(react@18.2.0) ··· 7917 7578 '@types/react': 7918 7579 optional: true 7919 7580 dependencies: 7920 - '@babel/runtime': 7.23.2 7581 + '@babel/runtime': 7.24.4 7921 7582 '@emotion/react': 11.10.4(@babel/core@7.24.4)(@types/react@18.2.37)(react@18.2.0) 7922 7583 '@emotion/styled': 11.10.4(@babel/core@7.24.4)(@emotion/react@11.10.4)(@types/react@18.2.37)(react@18.2.0) 7923 7584 '@mui/private-theming': 5.10.3(@types/react@18.2.37)(react@18.2.0) ··· 7989 7650 peerDependencies: 7990 7651 react: ^17.0.0 || ^18.0.0 7991 7652 dependencies: 7992 - '@babel/runtime': 7.23.2 7653 + '@babel/runtime': 7.24.4 7993 7654 '@types/prop-types': 15.7.9 7994 7655 '@types/react-is': 17.0.3 7995 7656 prop-types: 15.8.1 ··· 10613 10274 engines: {node: '>=12'} 10614 10275 dependencies: 10615 10276 '@babel/code-frame': 7.22.13 10616 - '@babel/runtime': 7.23.2 10277 + '@babel/runtime': 7.24.4 10617 10278 '@types/aria-query': 4.2.2 10618 10279 aria-query: 5.3.0 10619 10280 chalk: 4.1.2 ··· 10776 10437 peerDependencies: 10777 10438 '@testing-library/dom': '>=7.21.4' 10778 10439 dependencies: 10779 - '@babel/runtime': 7.23.2 10440 + '@babel/runtime': 7.24.4 10780 10441 '@testing-library/dom': 8.19.0 10781 10442 dev: true 10782 10443 ··· 10801 10462 /@tootallnate/once@1.1.2: 10802 10463 resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==} 10803 10464 engines: {node: '>= 6'} 10804 - dev: true 10805 - 10806 - /@tootallnate/once@2.0.0: 10807 - resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} 10808 - engines: {node: '>= 10'} 10809 10465 dev: true 10810 10466 10811 10467 /@tootallnate/quickjs-emscripten@0.23.0: ··· 10985 10641 10986 10642 /@types/fs-extra@8.1.3: 10987 10643 resolution: {integrity: sha512-7IdV01N0u/CaVO0fuY1YmEg14HQN3+EW8mpNgg6NEfxEl/lzCa5OxlBu3iFsCAdamnYOcTQ7oEi43Xc/67Rgzw==} 10988 - dependencies: 10989 - '@types/node': 20.12.7 10990 - dev: true 10991 - 10992 - /@types/fs-extra@9.0.13: 10993 - resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} 10994 10644 dependencies: 10995 10645 '@types/node': 20.12.7 10996 10646 dev: true ··· 11238 10888 11239 10889 /@types/parse5@5.0.3: 11240 10890 resolution: {integrity: sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw==} 11241 - dev: true 11242 - 11243 - /@types/prettier@2.7.0: 11244 - resolution: {integrity: sha512-RI1L7N4JnW5gQw2spvL7Sllfuf1SaHdrZpCHiBlCXjIlufi1SMNnbu2teze3/QE67Fg2tBlH7W+mi4hVNk4p0A==} 11245 10891 dev: true 11246 10892 11247 10893 /@types/prettier@2.7.3: ··· 13140 12786 13141 12787 /abab@2.0.6: 13142 12788 resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==} 12789 + deprecated: Use your platform's native atob() and btoa() methods instead 13143 12790 dev: true 13144 12791 13145 12792 /abbrev@1.1.1: ··· 13170 12817 dependencies: 13171 12818 acorn: 7.4.1 13172 12819 acorn-walk: 7.2.0 13173 - dev: true 13174 - 13175 - /acorn-globals@7.0.1: 13176 - resolution: {integrity: sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==} 13177 - dependencies: 13178 - acorn: 8.11.3 13179 - acorn-walk: 8.3.2 13180 12820 dev: true 13181 12821 13182 12822 /acorn-import-assertions@1.8.0(acorn@8.11.3): ··· 13219 12859 /acorn-walk@8.3.2: 13220 12860 resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} 13221 12861 engines: {node: '>=0.4.0'} 12862 + dev: false 13222 12863 13223 12864 /acorn@6.4.2: 13224 12865 resolution: {integrity: sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==} ··· 13245 12886 13246 12887 /acorn@8.11.3: 13247 12888 resolution: {integrity: sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==} 13248 - engines: {node: '>=0.4.0'} 13249 - hasBin: true 13250 - dev: true 13251 - 13252 - /acorn@8.9.0: 13253 - resolution: {integrity: sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==} 13254 12889 engines: {node: '>=0.4.0'} 13255 12890 hasBin: true 13256 12891 dev: true ··· 14380 14015 /broadcast-channel@3.7.0: 14381 14016 resolution: {integrity: sha512-cIAKJXAxGJceNZGTZSBzMxzyOn72cVgPnKx4dc6LRjQgbaJUQqhy5rzL3zbMxkMWsGKkv2hSFkPRMEXfoMZ2Mg==} 14382 14017 dependencies: 14383 - '@babel/runtime': 7.23.2 14018 + '@babel/runtime': 7.24.4 14384 14019 detect-node: 2.1.0 14385 14020 js-sha3: 0.8.0 14386 14021 microseconds: 0.2.0 ··· 15724 15359 /css-what@6.1.0: 15725 15360 resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==} 15726 15361 engines: {node: '>= 6'} 15362 + dev: true 15727 15363 15728 15364 /css.escape@1.5.1: 15729 15365 resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==} ··· 15743 15379 resolution: {integrity: sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==} 15744 15380 dev: true 15745 15381 15746 - /cssom@0.5.0: 15747 - resolution: {integrity: sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==} 15748 - dev: true 15749 - 15750 15382 /cssstyle@2.3.0: 15751 15383 resolution: {integrity: sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==} 15752 15384 engines: {node: '>=8'} 15753 15385 dependencies: 15754 15386 cssom: 0.3.8 15755 - dev: true 15756 - 15757 - /cssstyle@3.0.0: 15758 - resolution: {integrity: sha512-N4u2ABATi3Qplzf0hWbVCdjenim8F3ojEXpBDF5hBpjzW182MjNGLqfmQ0SkSPeQ+V86ZXgeH8aXj6kayd4jgg==} 15759 - engines: {node: '>=14'} 15760 - dependencies: 15761 - rrweb-cssom: 0.6.0 15762 15387 dev: true 15763 15388 15764 15389 /cssstyle@4.0.1: ··· 16004 15629 whatwg-url: 8.7.0 16005 15630 dev: true 16006 15631 16007 - /data-urls@3.0.2: 16008 - resolution: {integrity: sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==} 16009 - engines: {node: '>=12'} 16010 - dependencies: 16011 - abab: 2.0.6 16012 - whatwg-mimetype: 3.0.0 16013 - whatwg-url: 11.0.0 16014 - dev: true 16015 - 16016 - /data-urls@4.0.0: 16017 - resolution: {integrity: sha512-/mMTei/JXPqvFqQtfyTowxmJVwr2PVAeCcDxyFf6LhoOu/09TX2OX3kb2wzi4DMXcfj4OItwDOnhl5oziPnT6g==} 16018 - engines: {node: '>=14'} 16019 - dependencies: 16020 - abab: 2.0.6 16021 - whatwg-mimetype: 3.0.0 16022 - whatwg-url: 12.0.1 16023 - dev: true 16024 - 16025 15632 /data-urls@5.0.0: 16026 15633 resolution: {integrity: sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==} 16027 15634 engines: {node: '>=18'} ··· 16091 15698 /decimal.js-light@2.5.1: 16092 15699 resolution: {integrity: sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==} 16093 15700 dev: false 16094 - 16095 - /decimal.js@10.4.0: 16096 - resolution: {integrity: sha512-Nv6ENEzyPQ6AItkGwLE2PGKinZZ9g59vSh2BeH6NqPu0OTKZ5ruJsVqh/orbAnqXc9pBbgXAIrc2EyaCj8NpGg==} 16097 - dev: true 16098 15701 16099 15702 /decimal.js@10.4.3: 16100 15703 resolution: {integrity: sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==} ··· 16524 16127 deprecated: Use your platform's native DOMException instead 16525 16128 dependencies: 16526 16129 webidl-conversions: 5.0.0 16527 - dev: true 16528 - 16529 - /domexception@4.0.0: 16530 - resolution: {integrity: sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==} 16531 - engines: {node: '>=12'} 16532 - dependencies: 16533 - webidl-conversions: 7.0.0 16534 16130 dev: true 16535 16131 16536 16132 /domhandler@3.3.0: ··· 18749 18345 resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==} 18750 18346 engines: {node: '>=12'} 18751 18347 dependencies: 18752 - graceful-fs: 4.2.10 18348 + graceful-fs: 4.2.11 18753 18349 jsonfile: 6.1.0 18754 18350 universalify: 2.0.0 18755 18351 dev: true ··· 19063 18659 resolution: {integrity: sha512-w0dzqw/nt51xMVmlaV1+JRzN+oCa1KfcgGEWhxUG16wbdA+Xnt/yoFO8Z8x/V82ZcZ0wy6ln9QDup5avbhiDhQ==} 19064 18660 dev: true 19065 18661 19066 - /givens@1.3.9: 19067 - resolution: {integrity: sha512-4hYlStsEIaYeYvZTZwgD5yOS2WVP0dcDsOBqeImdEM8eLuclvv0IEMlQQ1kuA5DN4he7wVH1jsYtNe9uininxg==} 19068 - dev: true 19069 - 19070 18662 /glob-parent@3.1.0: 19071 18663 resolution: {integrity: sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==} 19072 18664 dependencies: ··· 19318 18910 responselike: 3.0.0 19319 18911 dev: true 19320 18912 19321 - /graceful-fs@4.2.10: 19322 - resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} 19323 - dev: true 19324 - 19325 18913 /graceful-fs@4.2.11: 19326 18914 resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} 19327 18915 ··· 19407 18995 wordwrap: 1.0.0 19408 18996 optionalDependencies: 19409 18997 uglify-js: 3.17.4 19410 - dev: true 19411 - 19412 - /happy-dom@12.10.3: 19413 - resolution: {integrity: sha512-JzUXOh0wdNGY54oKng5hliuBkq/+aT1V3YpTM+lrN/GoLQTANZsMaIvmHiHe612rauHvPJnDZkZ+5GZR++1Abg==} 19414 - dependencies: 19415 - css.escape: 1.5.1 19416 - entities: 4.5.0 19417 - iconv-lite: 0.6.3 19418 - webidl-conversions: 7.0.0 19419 - whatwg-encoding: 2.0.0 19420 - whatwg-mimetype: 3.0.0 19421 18998 dev: true 19422 18999 19423 19000 /happy-dom@14.3.10: ··· 19632 19209 resolution: {integrity: sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==} 19633 19210 dependencies: 19634 19211 '@babel/runtime': 7.18.9 19212 + dev: false 19635 19213 19636 19214 /hmac-drbg@1.0.1: 19637 19215 resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} ··· 19676 19254 engines: {node: '>=10'} 19677 19255 dependencies: 19678 19256 whatwg-encoding: 1.0.5 19679 - dev: true 19680 - 19681 - /html-encoding-sniffer@3.0.0: 19682 - resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==} 19683 - engines: {node: '>=12'} 19684 - dependencies: 19685 - whatwg-encoding: 2.0.0 19686 19257 dev: true 19687 19258 19688 19259 /html-encoding-sniffer@4.0.0: ··· 19800 19371 engines: {node: '>= 6'} 19801 19372 dependencies: 19802 19373 '@tootallnate/once': 1.1.2 19803 - agent-base: 6.0.2 19804 - debug: 4.3.4(supports-color@8.1.1) 19805 - transitivePeerDependencies: 19806 - - supports-color 19807 - dev: true 19808 - 19809 - /http-proxy-agent@5.0.0: 19810 - resolution: {integrity: sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==} 19811 - engines: {node: '>= 6'} 19812 - dependencies: 19813 - '@tootallnate/once': 2.0.0 19814 19374 agent-base: 6.0.2 19815 19375 debug: 4.3.4(supports-color@8.1.1) 19816 19376 transitivePeerDependencies: ··· 21466 21026 - utf-8-validate 21467 21027 dev: true 21468 21028 21469 - /jsdom@20.0.0: 21470 - resolution: {integrity: sha512-x4a6CKCgx00uCmP+QakBDFXwjAJ69IkkIWHmtmjd3wvXPcdOS44hfX2vqkOQrVrq8l9DhNNADZRXaCEWvgXtVA==} 21471 - engines: {node: '>=14'} 21472 - peerDependencies: 21473 - canvas: ^2.5.0 21474 - peerDependenciesMeta: 21475 - canvas: 21476 - optional: true 21477 - dependencies: 21478 - abab: 2.0.6 21479 - acorn: 8.9.0 21480 - acorn-globals: 6.0.0 21481 - cssom: 0.5.0 21482 - cssstyle: 2.3.0 21483 - data-urls: 3.0.2 21484 - decimal.js: 10.4.0 21485 - domexception: 4.0.0 21486 - escodegen: 2.0.0 21487 - form-data: 4.0.0 21488 - html-encoding-sniffer: 3.0.0 21489 - http-proxy-agent: 5.0.0 21490 - https-proxy-agent: 5.0.1 21491 - is-potential-custom-element-name: 1.0.1 21492 - nwsapi: 2.2.1 21493 - parse5: 7.0.0 21494 - saxes: 6.0.0 21495 - symbol-tree: 3.2.4 21496 - tough-cookie: 4.1.2 21497 - w3c-hr-time: 1.0.2 21498 - w3c-xmlserializer: 3.0.0 21499 - webidl-conversions: 7.0.0 21500 - whatwg-encoding: 2.0.0 21501 - whatwg-mimetype: 3.0.0 21502 - whatwg-url: 11.0.0 21503 - ws: 8.14.2 21504 - xml-name-validator: 4.0.0 21505 - transitivePeerDependencies: 21506 - - bufferutil 21507 - - supports-color 21508 - - utf-8-validate 21509 - dev: true 21510 - 21511 - /jsdom@21.0.0: 21512 - resolution: {integrity: sha512-AIw+3ZakSUtDYvhwPwWHiZsUi3zHugpMEKlNPaurviseYoBqo0zBd3zqoUi3LPCNtPFlEP8FiW9MqCZdjb2IYA==} 21513 - engines: {node: '>=14'} 21514 - peerDependencies: 21515 - canvas: ^2.5.0 21516 - peerDependenciesMeta: 21517 - canvas: 21518 - optional: true 21519 - dependencies: 21520 - abab: 2.0.6 21521 - acorn: 8.9.0 21522 - acorn-globals: 7.0.1 21523 - cssom: 0.5.0 21524 - cssstyle: 2.3.0 21525 - data-urls: 3.0.2 21526 - decimal.js: 10.4.3 21527 - domexception: 4.0.0 21528 - escodegen: 2.0.0 21529 - form-data: 4.0.0 21530 - html-encoding-sniffer: 3.0.0 21531 - http-proxy-agent: 5.0.0 21532 - https-proxy-agent: 5.0.1 21533 - is-potential-custom-element-name: 1.0.1 21534 - nwsapi: 2.2.4 21535 - parse5: 7.1.2 21536 - saxes: 6.0.0 21537 - symbol-tree: 3.2.4 21538 - tough-cookie: 4.1.2 21539 - w3c-xmlserializer: 4.0.0 21540 - webidl-conversions: 7.0.0 21541 - whatwg-encoding: 2.0.0 21542 - whatwg-mimetype: 3.0.0 21543 - whatwg-url: 11.0.0 21544 - ws: 8.14.2 21545 - xml-name-validator: 4.0.0 21546 - transitivePeerDependencies: 21547 - - bufferutil 21548 - - supports-color 21549 - - utf-8-validate 21550 - dev: true 21551 - 21552 - /jsdom@22.1.0: 21553 - resolution: {integrity: sha512-/9AVW7xNbsBv6GfWho4TTNjEo9fe6Zhf9O7s0Fhhr3u+awPwAJMKwAMXnkk5vBxflqLW9hTHX/0cs+P3gW+cQw==} 21554 - engines: {node: '>=16'} 21555 - peerDependencies: 21556 - canvas: ^2.5.0 21557 - peerDependenciesMeta: 21558 - canvas: 21559 - optional: true 21560 - dependencies: 21561 - abab: 2.0.6 21562 - cssstyle: 3.0.0 21563 - data-urls: 4.0.0 21564 - decimal.js: 10.4.3 21565 - domexception: 4.0.0 21566 - form-data: 4.0.0 21567 - html-encoding-sniffer: 3.0.0 21568 - http-proxy-agent: 5.0.0 21569 - https-proxy-agent: 5.0.1 21570 - is-potential-custom-element-name: 1.0.1 21571 - nwsapi: 2.2.7 21572 - parse5: 7.1.2 21573 - rrweb-cssom: 0.6.0 21574 - saxes: 6.0.0 21575 - symbol-tree: 3.2.4 21576 - tough-cookie: 4.1.3 21577 - w3c-xmlserializer: 4.0.0 21578 - webidl-conversions: 7.0.0 21579 - whatwg-encoding: 2.0.0 21580 - whatwg-mimetype: 3.0.0 21581 - whatwg-url: 12.0.1 21582 - ws: 8.14.2 21583 - xml-name-validator: 4.0.0 21584 - transitivePeerDependencies: 21585 - - bufferutil 21586 - - supports-color 21587 - - utf-8-validate 21588 - dev: true 21589 - 21590 21029 /jsdom@23.2.0: 21591 21030 resolution: {integrity: sha512-L88oL7D/8ufIES+Zjz7v0aes+oBMh2Xnh3ygWvL0OaICOomKEPKuPnIfBJekiXr+BHbbMjrWn/xqrDQuxFTeyA==} 21592 21031 engines: {node: '>=18'} ··· 22437 21876 /match-sorter@6.3.1: 22438 21877 resolution: {integrity: sha512-mxybbo3pPNuA+ZuCUhm5bwNkXrJTbsk5VWbR5wiwz/GC6LIiegBGn2w3O08UG/jdbYLinw51fSQ5xNU1U3MgBw==} 22439 21878 dependencies: 22440 - '@babel/runtime': 7.23.2 21879 + '@babel/runtime': 7.24.4 22441 21880 remove-accents: 0.4.2 22442 21881 dev: false 22443 21882 ··· 23672 23111 resolution: {integrity: sha512-Y1wZESM7VUThYY+4W+X4ySH2maqcA+p7UR+w8VWNWVAd6lwuXXWz/w/Cz43J/dI2I+PS6wD5N+bJUF+gjWvIqg==} 23673 23112 dev: true 23674 23113 23675 - /nwsapi@2.2.1: 23676 - resolution: {integrity: sha512-JYOWTeFoS0Z93587vRJgASD5Ut11fYl5NyihP3KrYBvMe1FRRs6RN7m20SA/16GM4P6hTnZjT+UmDOt38UeXNg==} 23677 - dev: true 23678 - 23679 - /nwsapi@2.2.4: 23680 - resolution: {integrity: sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==} 23681 - dev: true 23682 - 23683 23114 /nwsapi@2.2.7: 23684 23115 resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==} 23685 23116 dev: true ··· 24158 23589 resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} 24159 23590 dev: true 24160 23591 24161 - /parse5@7.0.0: 24162 - resolution: {integrity: sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g==} 24163 - dependencies: 24164 - entities: 4.5.0 24165 - dev: true 24166 - 24167 23592 /parse5@7.1.2: 24168 23593 resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} 24169 23594 dependencies: ··· 24285 23710 /path-type@4.0.0: 24286 23711 resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} 24287 23712 engines: {node: '>=8'} 24288 - 24289 - /pathe@1.1.0: 24290 - resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==} 24291 - dev: true 24292 23713 24293 23714 /pathe@1.1.1: 24294 23715 resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==} ··· 24659 24080 24660 24081 /prettier@2.3.0: 24661 24082 resolution: {integrity: sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==} 24662 - engines: {node: '>=10.13.0'} 24663 - hasBin: true 24664 - dev: true 24665 - 24666 - /prettier@2.7.1: 24667 - resolution: {integrity: sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==} 24668 24083 engines: {node: '>=10.13.0'} 24669 24084 hasBin: true 24670 24085 dev: true ··· 25330 24745 react: '>=16.6.0' 25331 24746 react-dom: '>=16.6.0' 25332 24747 dependencies: 25333 - '@babel/runtime': 7.23.2 24748 + '@babel/runtime': 7.24.4 25334 24749 dom-helpers: 5.2.1 25335 24750 loose-envify: 1.4.0 25336 24751 prop-types: 15.8.1 ··· 27901 27316 resolution: {integrity: sha512-eM+pCBxXO/njtF7vdFsHuqb+ElbxqtI4r5EAvk6grfAFyJ6IvWlSkfZ5T9ozC6xWw3Fj1fGoSmrl0gUs46JVIw==} 27902 27317 engines: {node: '>=6'} 27903 27318 27904 - /tough-cookie@4.1.2: 27905 - resolution: {integrity: sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==} 27906 - engines: {node: '>=6'} 27907 - dependencies: 27908 - psl: 1.9.0 27909 - punycode: 2.3.1 27910 - universalify: 0.2.0 27911 - url-parse: 1.5.10 27912 - dev: true 27913 - 27914 27319 /tough-cookie@4.1.3: 27915 27320 resolution: {integrity: sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==} 27916 27321 engines: {node: '>=6'} ··· 27933 27338 /tr46@2.1.0: 27934 27339 resolution: {integrity: sha512-15Ih7phfcdP5YxqiB+iDtLoaTz4Nd35+IiAv0kQ5FNKHzXgdWqPoTIqEDDJmXceQt4JZk6lVPT8lnDlPpGDppw==} 27935 27340 engines: {node: '>=8'} 27936 - dependencies: 27937 - punycode: 2.3.1 27938 - dev: true 27939 - 27940 - /tr46@3.0.0: 27941 - resolution: {integrity: sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==} 27942 - engines: {node: '>=12'} 27943 - dependencies: 27944 - punycode: 2.3.1 27945 - dev: true 27946 - 27947 - /tr46@4.1.1: 27948 - resolution: {integrity: sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==} 27949 - engines: {node: '>=14'} 27950 27341 dependencies: 27951 27342 punycode: 2.3.1 27952 27343 dev: true ··· 29366 28757 29367 28758 /w3c-hr-time@1.0.2: 29368 28759 resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} 28760 + deprecated: Use your platform's native performance.now() and performance.timeOrigin. 29369 28761 dependencies: 29370 28762 browser-process-hrtime: 1.0.0 29371 28763 dev: true ··· 29375 28767 engines: {node: '>=10'} 29376 28768 dependencies: 29377 28769 xml-name-validator: 3.0.0 29378 - dev: true 29379 - 29380 - /w3c-xmlserializer@3.0.0: 29381 - resolution: {integrity: sha512-3WFqGEgSXIyGhOmAFtlicJNMjEps8b1MG31NCA0/vOF9+nKMUW1ckhi9cnNHmf88Rzw5V+dwIwsm2C7X8k9aQg==} 29382 - engines: {node: '>=12'} 29383 - dependencies: 29384 - xml-name-validator: 4.0.0 29385 - dev: true 29386 - 29387 - /w3c-xmlserializer@4.0.0: 29388 - resolution: {integrity: sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==} 29389 - engines: {node: '>=14'} 29390 - dependencies: 29391 - xml-name-validator: 4.0.0 29392 28770 dev: true 29393 28771 29394 28772 /w3c-xmlserializer@5.0.0: ··· 29844 29222 /whatwg-mimetype@4.0.0: 29845 29223 resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==} 29846 29224 engines: {node: '>=18'} 29847 - dev: true 29848 - 29849 - /whatwg-url@11.0.0: 29850 - resolution: {integrity: sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==} 29851 - engines: {node: '>=12'} 29852 - dependencies: 29853 - tr46: 3.0.0 29854 - webidl-conversions: 7.0.0 29855 - dev: true 29856 - 29857 - /whatwg-url@12.0.1: 29858 - resolution: {integrity: sha512-Ed/LrqB8EPlGxjS+TrsXcpUond1mhccS3pchLhzSgPCnTimUCKj3IZE75pAs5m6heB2U2TMerKFUXheyHY+VDQ==} 29859 - engines: {node: '>=14'} 29860 - dependencies: 29861 - tr46: 4.1.1 29862 - webidl-conversions: 7.0.0 29863 29225 dev: true 29864 29226 29865 29227 /whatwg-url@14.0.0: ··· 30477 29839 name: subpackage 30478 29840 dev: false 30479 29841 30480 - file:test/env-custom/vitest-environment-custom: 30481 - resolution: {directory: test/env-custom/vitest-environment-custom, type: directory} 29842 + file:test/core/deps/dep1: 29843 + resolution: {directory: test/core/deps/dep1, type: directory} 29844 + name: '@vitest/test-dep1' 29845 + dev: true 29846 + 29847 + file:test/core/deps/dep2: 29848 + resolution: {directory: test/core/deps/dep2, type: directory} 29849 + name: '@vitest/test-dep2' 29850 + dependencies: 29851 + '@vitest/test-dep1': file:test/core/deps/dep1 29852 + dev: true 29853 + 29854 + file:test/core/vitest-environment-custom: 29855 + resolution: {directory: test/core/vitest-environment-custom, type: directory} 30482 29856 name: vitest-environment-custom 30483 29857 dev: true 30484 29858 30485 29859 file:test/optimize-deps/dep-url: 30486 29860 resolution: {directory: test/optimize-deps/dep-url, type: directory} 30487 29861 name: '@vitest/test-deps-url' 30488 - dev: true 30489 - 30490 - file:test/vite-node/deps/dep1: 30491 - resolution: {directory: test/vite-node/deps/dep1, type: directory} 30492 - name: '@vitest/test-dep1' 30493 - dev: true 30494 - 30495 - file:test/vite-node/deps/dep2: 30496 - resolution: {directory: test/vite-node/deps/dep2, type: directory} 30497 - name: '@vitest/test-dep2' 30498 - dependencies: 30499 - '@vitest/test-dep1': file:test/vite-node/deps/dep1 30500 29862 dev: true
+31
test/README.md
··· 1 + Tests are split by categories. Default categories are: 2 + 3 + ## core 4 + 5 + These tests are running in different pools with a single config file. If you just need to test a function call, you can place your test here. 6 + 7 + This is the only test category that doesn't start new Vitest instance for every test. 8 + 9 + ## config 10 + 11 + Place your test here if you are testing a config opton. 12 + 13 + ## cli 14 + 15 + If you are testing a complex interaction, place your tests here. 16 + 17 + ## browser 18 + 19 + If you are testing browser mode, add your tests here. 20 + 21 + ## ui 22 + 23 + These are e2e tests for UI package. We are using `playwright` to test it. 24 + 25 + ## watch 26 + 27 + Place your tests here if you are testing Vitest behaviour when file is created/updated/removed. 28 + 29 + ---- 30 + 31 + All other categories just group tests by type.
+6 -25
.github/workflows/ci.yml
··· 32 32 - name: Lint 33 33 run: pnpm run lint 34 34 35 - typecheck: 36 - runs-on: ubuntu-latest 37 - steps: 38 - - uses: actions/checkout@v4 39 - 40 - - uses: ./.github/actions/setup-and-cache 41 - 42 - - name: Install 43 - run: pnpm i 44 - 45 - - name: Build 46 - run: pnpm run build 47 - 48 - - name: Typecheck 49 - run: pnpm run typecheck 50 - 51 35 test: 52 36 runs-on: ${{ matrix.os }} 53 37 ··· 85 69 - name: Test 86 70 run: pnpm run test:ci 87 71 88 - - name: Test No Threads 89 - run: pnpm run test:ci:no-threads 90 - 91 - - name: Test Vm Threads 92 - run: pnpm run test:ci:vm-threads 72 + - name: Test Examples 73 + run: pnpm run test:examples 93 74 94 75 test-ui: 95 76 runs-on: ubuntu-latest ··· 147 128 148 129 timeout-minutes: 30 149 130 150 - env: 151 - BROWSER: ${{ matrix.browser[0] }} 152 131 steps: 153 132 - uses: actions/checkout@v4 154 133 ··· 170 149 171 150 - name: Test Browser (webdriverio) 172 151 run: pnpm run test:browser:webdriverio 152 + env: 153 + BROWSER: ${{ matrix.browser[0] }} 173 154 174 155 - name: Test Browser (playwright) 175 156 run: pnpm run test:browser:playwright ··· 185 166 186 167 timeout-minutes: 30 187 168 188 - env: 189 - BROWSER: ${{ matrix.browser[0] }} 190 169 steps: 191 170 - uses: actions/checkout@v4 192 171 ··· 208 187 209 188 - name: Test Browser (webdriverio) 210 189 run: pnpm run test:browser:webdriverio 190 + env: 191 + BROWSER: ${{ matrix.browser[0] }} 211 192 212 193 - name: Test Browser (playwright) 213 194 run: pnpm run test:browser:playwright
-14
test/bail/package.json
··· 1 - { 2 - "name": "@vitest/test-bail", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "@vitest/browser": "workspace:*", 10 - "vite": "latest", 11 - "vitest": "workspace:*", 12 - "webdriverio": "latest" 13 - } 14 - }
-15
test/bail/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - reporters: 'verbose', 6 - include: ['test/**/*.test.*'], 7 - env: { CI: 'true' }, 8 - 9 - // For Windows CI mostly 10 - testTimeout: process.env.CI ? 30_000 : 10_000, 11 - chaiConfig: { 12 - truncateThreshold: 999, 13 - }, 14 - }, 15 - })
-12
test/base/package.json
··· 1 - { 2 - "name": "@vitest/test-base", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "vitest": "workspace:*" 11 - } 12 - }
-5
test/base/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - base: '/some/base/url', 5 - })
+4 -3
test/browser/package.json
··· 4 4 "private": true, 5 5 "scripts": { 6 6 "test": "pnpm run test:webdriverio && pnpm run test:playwright", 7 - "test:webdriverio": "PROVIDER=webdriverio node --test --test-concurrency=1 specs/", 8 - "test:playwright": "PROVIDER=playwright node --test --test-concurrency=1 specs/", 9 - "test:safaridriver": "PROVIDER=webdriverio BROWSER=safari node --test --test-concurrency=1 specs/", 7 + "test:unit": "vitest --no-watch --config=vitest.config.unit.mts", 8 + "test:webdriverio": "PROVIDER=webdriverio pnpm run test:unit", 9 + "test:playwright": "PROVIDER=playwright pnpm run test:unit", 10 + "test:safaridriver": "PROVIDER=webdriverio BROWSER=safari pnpm run test:unit", 10 11 "test-fixtures": "vitest", 11 12 "coverage": "vitest --coverage.enabled --coverage.provider=istanbul --browser.headless=yes" 12 13 },
-1
test/browser/tsconfig.json
··· 1 1 { 2 2 "compilerOptions": { 3 - "rootDir": ".", 4 3 "module": "ESNext", 5 4 "moduleResolution": "Bundler", 6 5 "paths": {
+1 -1
test/browser/vitest.config.mts
··· 6 6 7 7 function noop() {} 8 8 9 - const provider = process.env.PROVIDER || 'webdriverio' 9 + const provider = process.env.PROVIDER || 'playwright' 10 10 const browser = process.env.BROWSER || (provider === 'playwright' ? 'chromium' : 'chrome') 11 11 12 12 export default defineConfig({
+14
test/browser/vitest.config.unit.mts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({ 4 + test: { 5 + include: ['specs/**/*.{spec,test}.ts'], 6 + poolOptions: { 7 + threads: { 8 + singleThread: true, 9 + }, 10 + }, 11 + hookTimeout: process.env.CI ? 120_000 : 10_000, 12 + testTimeout: process.env.CI ? 120_000 : 10_000, 13 + }, 14 + })
-11
test/changed/package.json
··· 1 - { 2 - "name": "@vitest/test-changed", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-9
test/changed/vitest.config.js
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['tests/**/*.test.ts'], 6 - testTimeout: 60_000, 7 - hookTimeout: 60_000, 8 - }, 9 - })
-21
test/cjs/package.json
··· 1 - { 2 - "name": "@vitest/test-cjs", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@types/fs-extra": "^9.0.13", 11 - "@types/lodash": "^4.14.201", 12 - "@types/prettier": "^2.6.1", 13 - "fs-extra": "^10.1.0", 14 - "givens": "1.3.9", 15 - "history": "^5.3.0", 16 - "lodash": "^4.17.21", 17 - "prettier": "^2.6.2", 18 - "temp-dir": "^2.0.0", 19 - "vitest": "workspace:*" 20 - } 21 - }
-5
test/cjs/tsconfig.json
··· 1 - { 2 - "compilerOptions": { 3 - "esModuleInterop": true 4 - } 5 - }
-9
test/cjs/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - deps: { 6 - interopDefault: true, 7 - }, 8 - }, 9 - })
+41
test/cli/custom.ts
··· 1 + import vm from 'node:vm' 2 + import debug from 'debug' 3 + import type { Environment } from 'vitest' 4 + 5 + // test that external packages (debug) are loaded correctly 6 + const log = debug('test:env') 7 + 8 + export default <Environment>{ 9 + name: 'custom', 10 + transformMode: 'ssr', 11 + setupVM({ custom }) { 12 + const context = vm.createContext({ 13 + testEnvironment: 'custom', 14 + option: custom.option, 15 + setTimeout, 16 + clearTimeout, 17 + }) 18 + return { 19 + getVmContext() { 20 + return context 21 + }, 22 + teardown() { 23 + delete context.testEnvironment 24 + delete context.option 25 + }, 26 + } 27 + }, 28 + setup(global, { custom }) { 29 + global.testEnvironment = 'custom' 30 + global.option = custom.option 31 + return { 32 + teardown() { 33 + delete global.testEnvironment 34 + delete global.option 35 + 36 + if (global.__exists) 37 + log('should not log') 38 + }, 39 + } 40 + }, 41 + }
+9 -2
test/cli/package.json
··· 3 3 "type": "module", 4 4 "private": true, 5 5 "scripts": { 6 - "test": "vitest --exclude fixtures/exclude/**/string.test.ts" 6 + "test": "vitest" 7 7 }, 8 8 "devDependencies": { 9 + "@types/debug": "^4.1.12", 10 + "@types/ws": "^8.5.9", 11 + "@vitejs/plugin-basic-ssl": "^1.0.2", 12 + "@vitest/runner": "workspace:^", 13 + "debug": "^4.3.4", 14 + "execa": "^8.0.1", 9 15 "vite": "latest", 10 - "vitest": "workspace:*" 16 + "vitest": "workspace:*", 17 + "ws": "^8.14.2" 11 18 } 12 19 }
+5
test/cli/vitest.config.ts
··· 5 5 include: ['test/**.test.ts'], 6 6 reporters: ['verbose'], 7 7 testTimeout: 60_000, 8 + poolOptions: { 9 + threads: { 10 + singleThread: true, 11 + }, 12 + }, 8 13 chaiConfig: { 9 14 truncateThreshold: 999, 10 15 },
+4
test/config/tsconfig.json
··· 1 1 { 2 2 "extends": "../../tsconfig.base.json", 3 + "compilerOptions": { 4 + "lib": ["DOM", "ESNext"], 5 + "types": ["vite/client"] 6 + }, 3 7 "exclude": [ 4 8 "**/dist/**" 5 9 ]
+5
test/config/vitest.config.ts
··· 6 6 include: ['test/**.test.ts'], 7 7 reporters: ['verbose'], 8 8 testTimeout: 60_000, 9 + poolOptions: { 10 + threads: { 11 + singleThread: true, 12 + }, 13 + }, 9 14 chaiConfig: { 10 15 truncateThreshold: 999, 11 16 },
+11
test/core/index.html
··· 1 + <!DOCTYPE html> 2 + <html lang="en"> 3 + <head> 4 + <meta charset="UTF-8"> 5 + <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 + <title>Core Tests</title> 7 + </head> 8 + <body> 9 + Nothing is rendered 10 + </body> 11 + </html>
+10 -1
test/core/package.json
··· 4 4 "private": true, 5 5 "scripts": { 6 6 "test": "vitest", 7 + "test:threads": "vitest --project threads", 8 + "test:forks": "vitest --project forks", 9 + "test:vmThreads": "vitest --project vmThreads", 7 10 "dev": "vite", 8 11 "coverage": "vitest run --coverage" 9 12 }, 10 13 "devDependencies": { 14 + "@types/debug": "^4.1.12", 11 15 "@vitest/expect": "workspace:*", 12 16 "@vitest/runner": "workspace:*", 17 + "@vitest/test-dep1": "file:./deps/dep1", 18 + "@vitest/test-dep2": "file:./deps/dep2", 13 19 "@vitest/utils": "workspace:*", 20 + "@vitest/web-worker": "workspace:^", 21 + "debug": "^4.3.4", 14 22 "strip-ansi": "^7.1.0", 15 23 "tinyspy": "^1.0.2", 16 24 "url": "^0.11.0", 17 - "vitest": "workspace:*" 25 + "vitest": "workspace:*", 26 + "vitest-environment-custom": "file:./vitest-environment-custom" 18 27 } 19 28 }
+44 -2
test/core/vite.config.ts
··· 36 36 '__NULL__': null, 37 37 '__ZERO__': 0, 38 38 '__FALSE__': false, 39 + 'import.meta.vitest': false, 39 40 }, 40 41 resolve: { 41 42 alias: [ ··· 48 49 port: 3022, 49 50 }, 50 51 test: { 52 + api: { 53 + port: 3023, 54 + }, 51 55 name: 'core', 56 + includeSource: [ 57 + 'src/in-source/*.ts', 58 + ], 52 59 exclude: ['**/fixtures/**', ...defaultExclude], 53 60 slowTestThreshold: 1000, 54 - testTimeout: 2000, 61 + testTimeout: process.env.CI ? 10_000 : 5_000, 55 62 setupFiles: [ 56 63 './test/setup.ts', 57 64 ], ··· 59 66 coverage: { 60 67 provider: 'istanbul', 61 68 reporter: ['text', 'html'], 69 + }, 70 + environmentMatchGlobs: [ 71 + ['**/*.dom.test.ts', 'happy-dom'], 72 + ['test/env-glob-dom/**', 'jsdom'], 73 + ], 74 + poolMatchGlobs: [ 75 + ['**/test/*.child_process.test.ts', 'forks'], 76 + ['**/test/*.threads.test.ts', 'threads'], 77 + ], 78 + environmentOptions: { 79 + custom: { 80 + option: 'config-option', 81 + }, 82 + }, 83 + poolOptions: { 84 + threads: { 85 + execArgv: ['--experimental-wasm-modules'], 86 + }, 87 + forks: { 88 + execArgv: ['--experimental-wasm-modules'], 89 + }, 62 90 }, 63 91 env: { 64 92 CUSTOM_ENV: 'foo', ··· 71 99 sequence: { 72 100 seed: 101, 73 101 }, 102 + allowOnly: true, 74 103 deps: { 75 104 moduleDirectories: ['node_modules', 'projects', 'packages'], 76 105 }, 77 106 server: { 78 107 deps: { 79 - external: ['tinyspy', /src\/external/, /esm\/esm/], 108 + external: [ 109 + 'tinyspy', 110 + /src\/external/, 111 + /esm\/esm/, 112 + /packages\/web-worker/, 113 + /\.wasm$/, 114 + /\/wasm-bindgen-no-cyclic\/index_bg.js/, 115 + ], 80 116 inline: ['inline-lib'], 81 117 }, 82 118 }, ··· 88 124 customResolver: () => resolve(__dirname, 'src', 'aliased-mod.ts'), 89 125 }, 90 126 ], 127 + onConsoleLog(log) { 128 + if (log.includes('Failed to load url') && log.includes('web-worker')) 129 + return false 130 + if (log.includes('Importing WebAssembly ')) 131 + return false 132 + }, 91 133 }, 92 134 })
+18
test/core/vitest.workspace.ts
··· 1 + import type { Pool } from 'vitest' 2 + import { defineWorkspace } from 'vitest/config' 3 + 4 + function project(pool: Pool) { 5 + return { 6 + extends: './vite.config.ts', 7 + test: { 8 + name: pool, 9 + pool, 10 + }, 11 + } 12 + } 13 + 14 + export default defineWorkspace([ 15 + project('threads'), 16 + project('forks'), 17 + project('vmThreads'), 18 + ])
-13
test/css/package.json
··· 1 - { 2 - "name": "@vitest/test-css", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "node testing.mjs", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "jsdom": "^20.0.0", 11 - "vitest": "workspace:*" 12 - } 13 - }
-28
test/css/testing.mjs
··· 1 - import { startVitest } from 'vitest/node' 2 - 3 - const configs = [ 4 - ['test/default-css', {}], 5 - ['test/process-css', { include: [/App\.css/] }], 6 - [['test/process-module', 'test/process-inline'], { include: [/App\.module\.css/] }], 7 - ['test/scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'scoped' } }], 8 - ['test/non-scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'non-scoped' } }], 9 - ] 10 - 11 - async function runTests() { 12 - for (const [name, config] of configs) { 13 - const names = Array.isArray(name) ? name : [name] 14 - await startVitest('test', names, { 15 - run: true, 16 - css: config, 17 - update: false, 18 - teardownTimeout: 1000_000_000, 19 - }) 20 - 21 - if (process.exitCode) 22 - process.exit() 23 - } 24 - 25 - process.exit(0) 26 - } 27 - 28 - runTests()
-7
test/css/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - environment: 'jsdom', 6 - }, 7 - })
-11
test/cwd/package.json
··· 1 - { 2 - "name": "@vitest/test-cwd", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "cd $(pwd)/.cache/projects/test && vitest run" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-3
test/cwd/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({})
-14
test/edge-runtime/package.json
··· 1 - { 2 - "name": "@vitest/test-edge-runtime", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@edge-runtime/vm": "1.1.0-beta.26", 11 - "@vitest/web-worker": "workspace:*", 12 - "vitest": "workspace:*" 13 - } 14 - }
-7
test/edge-runtime/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - environment: 'node', 6 - }, 7 - })
-11
test/empty-test/package.json
··· 1 - { 2 - "name": "@vitest/test-empty-test", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest run --passWithNoTests" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-3
test/empty-test/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({})
-41
test/env-custom-file/custom.ts
··· 1 - import vm from 'node:vm' 2 - import debug from 'debug' 3 - import type { Environment } from 'vitest' 4 - 5 - // test that external packages (debug) are loaded correctly 6 - const log = debug('test:env') 7 - 8 - export default <Environment>{ 9 - name: 'custom', 10 - transformMode: 'ssr', 11 - setupVM({ custom }) { 12 - const context = vm.createContext({ 13 - testEnvironment: 'custom', 14 - option: custom.option, 15 - setTimeout, 16 - clearTimeout, 17 - }) 18 - return { 19 - getVmContext() { 20 - return context 21 - }, 22 - teardown() { 23 - delete context.testEnvironment 24 - delete context.option 25 - }, 26 - } 27 - }, 28 - setup(global, { custom }) { 29 - global.testEnvironment = 'custom' 30 - global.option = custom.option 31 - return { 32 - teardown() { 33 - delete global.testEnvironment 34 - delete global.option 35 - 36 - if (global.__exists) 37 - log('should not log') 38 - }, 39 - } 40 - }, 41 - }
-14
test/env-custom-file/package.json
··· 1 - { 2 - "name": "@vitest/test-env-custom-file", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@types/debug": "^4.1.12", 11 - "debug": "^4.3.4", 12 - "vitest": "workspace:*" 13 - } 14 - }
-12
test/env-custom-file/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - environment: './custom.ts', 6 - environmentOptions: { 7 - custom: { 8 - option: 'config-option', 9 - }, 10 - }, 11 - }, 12 - })
-15
test/env-custom/package.json
··· 1 - { 2 - "name": "@vitest/test-env-custom", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@types/debug": "^4.1.12", 11 - "debug": "^4.3.4", 12 - "vitest": "workspace:*", 13 - "vitest-environment-custom": "file:./vitest-environment-custom" 14 - } 15 - }
-12
test/env-custom/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - environment: 'custom', 6 - environmentOptions: { 7 - custom: { 8 - option: 'config-option', 9 - }, 10 - }, 11 - }, 12 - })
-12
test/env-glob/package.json
··· 1 - { 2 - "name": "@vitest/test-env-glob", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "vitest": "workspace:*" 11 - } 12 - }
-10
test/env-glob/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - environmentMatchGlobs: [ 6 - ['**/*.dom.test.ts', 'happy-dom'], 7 - ['test/dom/**', 'jsdom'], 8 - ], 9 - }, 10 - })
-13
test/env-mixed/package.json
··· 1 - { 2 - "name": "@vitest/test-env-mixed", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "happy-dom": "latest", 10 - "vite": "latest", 11 - "vitest": "workspace:*" 12 - } 13 - }
-11
test/env-mixed/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['./test/**/*'], 6 - testTimeout: process.env.CI ? 30_000 : 10_000, 7 - chaiConfig: { 8 - truncateThreshold: 0, 9 - }, 10 - }, 11 - })
-16
test/esm/package.json
··· 1 - { 2 - "name": "@vitest/test-esm", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "dependencies": { 10 - "css-what": "6.1.0", 11 - "tslib": "2.4.0" 12 - }, 13 - "devDependencies": { 14 - "vitest": "workspace:*" 15 - } 16 - }
-9
test/esm/vite.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - deps: { 6 - external: [/tslib/, /css-what/, /prototype\.mjs/], 7 - }, 8 - }, 9 - })
-13
test/failing/package.json
··· 1 - { 2 - "name": "@vitest/test-failing", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@vitest/runner": "workspace:*", 11 - "vitest": "workspace:*" 12 - } 13 - }
-10
test/failing/vite.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['test/*.test.ts'], 6 - chaiConfig: { 7 - truncateThreshold: 0, 8 - }, 9 - }, 10 - })
-14
test/fails/package.json
··· 1 - { 2 - "name": "@vitest/test-fails", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@vitest/coverage-istanbul": "workspace:*", 11 - "jsdom": "^21.0.0", 12 - "vitest": "workspace:*" 13 - } 14 - }
-10
test/fails/vite.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['test/*.test.ts'], 6 - chaiConfig: { 7 - truncateThreshold: 0, 8 - }, 9 - }, 10 - })
-12
test/filters/package.json
··· 1 - { 2 - "name": "@vitest/test-filters", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "vite": "latest", 10 - "vitest": "workspace:*" 11 - } 12 - }
-8
test/filters/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - reporters: 'verbose', 6 - include: ['test/**/*.test.*'], 7 - }, 8 - })
-11
test/global-setup-fail/package.json
··· 1 - { 2 - "name": "@vitest/test-global-setup-fail", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-7
test/global-setup-fail/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['test/*.test.ts'], 6 - }, 7 - })
-1
test/global-setup/vitest.config.ts
··· 15 15 }, 16 16 ], 17 17 test: { 18 - globals: true, 19 18 globalSetup: [ 20 19 './globalSetup/default-export.js', 21 20 './globalSetup/named-exports.js',
-13
test/import-meta/package.json
··· 1 - { 2 - "name": "@vitest/test-import-meta", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "build": "vite build", 8 - "coverage": "vitest run --coverage" 9 - }, 10 - "devDependencies": { 11 - "vitest": "workspace:*" 12 - } 13 - }
-20
test/import-meta/vite.config.ts
··· 1 - import { resolve } from 'pathe' 2 - import { defineConfig } from 'vite' 3 - 4 - export default defineConfig({ 5 - test: { 6 - includeSource: [ 7 - 'src/**/*.ts', 8 - ], 9 - }, 10 - define: { 11 - 'import.meta.vitest': false, 12 - }, 13 - build: { 14 - lib: { 15 - formats: ['es', 'cjs'], 16 - entry: resolve(__dirname, 'src/index.ts'), 17 - fileName: 'index', 18 - }, 19 - }, 20 - })
-13
test/inspect/package.json
··· 1 - { 2 - "name": "@vitest/test-inspect", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "vite": "latest", 10 - "vitest": "workspace:*", 11 - "ws": "^8.14.2" 12 - } 13 - }
-7
test/inspect/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['./test/**'], 6 - }, 7 - })
-12
test/mixed-pools/package.json
··· 1 - { 2 - "name": "@vitest/test-mixed-pools", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "vitest": "workspace:*" 11 - } 12 - }
-11
test/mixed-pools/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['test/*.test.ts'], 6 - poolMatchGlobs: [ 7 - ['**/test/*.child_process.test.ts', 'forks'], 8 - ['**/test/*.threads.test.ts', 'threads'], 9 - ], 10 - }, 11 - })
-11
test/network-imports/package.json
··· 1 - { 2 - "name": "@vitest/test-network-imports", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-24
test/network-imports/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - poolOptions: { 6 - threads: { 7 - execArgv: ['--experimental-network-imports'], 8 - }, 9 - forks: { 10 - execArgv: ['--experimental-network-imports'], 11 - }, 12 - // not supported? 13 - // FAIL test/basic.test.ts [ test/basic.test.ts ] 14 - // Error: ENOENT: no such file or directory, open 'http://localhost:9602/slash@3.0.0.js' 15 - // ❯ Object.openSync node:fs:596:3 16 - // ❯ readFileSync node:fs:464:35 17 - vmThreads: { 18 - execArgv: ['--experimental-network-imports'], 19 - }, 20 - }, 21 - // let vite serve public/slash@3.0.0.js 22 - api: 9602, 23 - }, 24 - })
-1
test/path-resolution-target/.eslintignore
··· 1 - !dist/
-1
test/path-resolution-target/.gitignore
··· 1 - !dist/
-2
test/path-resolution-target/README.md
··· 1 - This package is here just to be a sibling package to `path-resolution`. It 2 - contains no tests of its own.
-6
test/path-resolution-target/package.json
··· 1 - { 2 - "name": "@vitest/test-path-resolution-target", 3 - "type": "module", 4 - "private": true, 5 - "main": "./dist/index.js" 6 - }
-15
test/path-resolution/package.json
··· 1 - { 2 - "name": "@vitest/test-path-resolution", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@edge-runtime/vm": "1.1.0-beta.26", 11 - "@vitest/test-path-resolution-target": "workspace:*", 12 - "@vitest/web-worker": "workspace:*", 13 - "vitest": "workspace:*" 14 - } 15 - }
-7
test/path-resolution/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['test/*.test.ts'], 6 - }, 7 - })
-13
test/public-api/package.json
··· 1 - { 2 - "name": "@vitest/test-public-api", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "fixtures": "vitest --root ./fixtures" 8 - }, 9 - "devDependencies": { 10 - "@vitest/browser": "workspace:*", 11 - "vitest": "workspace:*" 12 - } 13 - }
-10
test/public-api/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['tests/**/*.spec.ts'], 6 - chaiConfig: { 7 - truncateThreshold: 0, 8 - }, 9 - }, 10 - })
-13
test/resolve/package.json
··· 1 - { 2 - "name": "@vitest/test-resolve", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "happy-dom": "^12.10.3", 11 - "vitest": "workspace:*" 12 - } 13 - }
-15
test/resolve/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - environmentMatchGlobs: [ 6 - ['**/web.test.ts', 'happy-dom'], 7 - ['**/ssr.test.ts', 'node'], 8 - ], 9 - server: { 10 - deps: { 11 - external: [/pkg-/], 12 - }, 13 - }, 14 - }, 15 - })
-13
test/restricted/package.json
··· 1 - { 2 - "name": "@vitest/test-restricted", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "jsdom": "^22.1.0", 11 - "vitest": "workspace:*" 12 - } 13 - }
-29
test/restricted/vitest.config.ts
··· 1 - import { resolve } from 'pathe' 2 - import { defineConfig } from 'vite' 3 - 4 - export default defineConfig({ 5 - plugins: [ 6 - { 7 - // simulates restrictive FS 8 - name: 'restrict-fs', 9 - config() { 10 - return { 11 - server: { 12 - fs: { 13 - allow: [ 14 - resolve(__dirname, 'src'), 15 - ], 16 - }, 17 - }, 18 - } 19 - }, 20 - }, 21 - ], 22 - test: { 23 - environment: 'jsdom', 24 - include: ['tests/**/*.spec.{js,ts}'], 25 - setupFiles: [ 26 - './vitest.setup.js', 27 - ], 28 - }, 29 - })
-1
test/restricted/vitest.setup.js
··· 1 - globalThis.SOME_TEST_VARIABLE = '3'
-12
test/run-once/package.json
··· 1 - { 2 - "name": "@vitest/test-run-once", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "vitest": "workspace:*" 11 - } 12 - }
-7
test/run-once/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - isolate: false, 6 - }, 7 - })
-14
test/run/package.json
··· 1 - { 2 - "name": "@vitest/test-run", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "@vitest/runner": "workspace:*", 10 - "execa": "^7.1.1", 11 - "vite": "latest", 12 - "vitest": "workspace:*" 13 - } 14 - }
-12
test/run/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - reporters: 'verbose', 6 - include: ['test/**/*.test.*'], 7 - chaiConfig: { 8 - truncateThreshold: 0, 9 - }, 10 - testTimeout: process.env.CI ? 60_000 : 10_000, 11 - }, 12 - })
-11
test/setup/package.json
··· 1 - { 2 - "name": "@vitest/test-setup", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-11
test/shard/package.json
··· 1 - { 2 - "name": "@vitest/test-shard", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest run shard-test.test.ts" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-50
test/shard/shard-test.test.ts
··· 1 - import { type UserConfig, expect, test } from 'vitest' 2 - import { basename } from 'pathe' 3 - 4 - import * as testUtils from '../test-utils' 5 - 6 - function runVitest(config: UserConfig) { 7 - return testUtils.runVitest({ ...config, dir: './test' }) 8 - } 9 - 10 - function parsePaths(stdout: string) { 11 - return Array.from(new Set(stdout 12 - .split('\n') 13 - .filter(line => line && line.includes('.test.js')) 14 - .map(file => basename(file.trim().split(' ')[1])) 15 - .sort())) 16 - } 17 - 18 - test('--shard=1/1', async () => { 19 - const { stdout } = await runVitest({ shard: '1/1' }) 20 - 21 - const paths = parsePaths(stdout) 22 - 23 - expect(paths).toEqual(['1.test.js', '2.test.js', '3.test.js']) 24 - }) 25 - 26 - test('--shard=1/2', async () => { 27 - const { stdout } = await runVitest({ shard: '1/2' }) 28 - 29 - const paths = parsePaths(stdout) 30 - 31 - expect(paths).toEqual(['1.test.js', '2.test.js']) 32 - }) 33 - 34 - test('--shard=2/2', async () => { 35 - const { stdout } = await runVitest({ shard: '2/2' }) 36 - 37 - const paths = parsePaths(stdout) 38 - 39 - expect(paths).toEqual(['3.test.js']) 40 - }) 41 - 42 - test('--shard=4/4', async () => { 43 - const { stdout } = await runVitest({ shard: '4/4' }) 44 - 45 - const paths = parsePaths(stdout) 46 - 47 - // project only has 3 files 48 - // shards > 3 are empty 49 - expect(paths).toEqual([]) 50 - })
-7
test/shard/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - testTimeout: 50_000, 6 - }, 7 - })
-12
test/single-thread/package.json
··· 1 - { 2 - "name": "@vitest/test-single-thread", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "vitest": "workspace:*" 11 - } 12 - }
-15
test/single-thread/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - import { BaseSequencer, type WorkspaceSpec } from 'vitest/node' 3 - 4 - export default defineConfig({ 5 - test: { 6 - pool: 'forks', 7 - sequence: { 8 - sequencer: class Sequences extends BaseSequencer { 9 - public async sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]> { 10 - return files.sort() 11 - } 12 - }, 13 - }, 14 - }, 15 - })
-12
test/stacktraces/package.json
··· 1 - { 2 - "name": "@vitest/test-stacktraces", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "vitest": "workspace:*" 11 - } 12 - }
-10
test/stacktraces/vite.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - esbuild: { 5 - sourcemap: 'both', 6 - }, 7 - test: { 8 - include: ['test/*.test.ts'], 9 - }, 10 - })
+6 -1
test/test-utils/index.ts
··· 2 2 import fs from 'node:fs' 3 3 import { fileURLToPath } from 'node:url' 4 4 import type { UserConfig as ViteUserConfig } from 'vite' 5 - import { type UserConfig, type VitestRunMode, afterEach } from 'vitest' 5 + import { type UserConfig, type VitestRunMode, type WorkerGlobalState, afterEach } from 'vitest' 6 6 import type { Vitest } from 'vitest/node' 7 7 import { startVitest } from 'vitest/node' 8 8 import { type Options, execa } from 'execa' ··· 133 133 const { vitest, ...rest } = await runCli('vite-node', _options, ...args) 134 134 135 135 return { viteNode: vitest, ...rest } 136 + } 137 + 138 + export function getInternalState(): WorkerGlobalState { 139 + // @ts-expect-error untyped global 140 + return globalThis.__vitest_worker__ 136 141 } 137 142 138 143 const originalFiles = new Map<string, string>()
-13
test/utils/package.json
··· 1 - { 2 - "name": "@vitest/test-utils", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@vitest/utils": "workspace:*", 11 - "vitest": "workspace:*" 12 - } 13 - }
-13
test/vite-config/package.json
··· 1 - { 2 - "name": "@vitest/test-vite-config", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "pathe": "^1.1.0", 11 - "vitest": "workspace:*" 12 - } 13 - }
-17
test/vite-config/vite.config.ts
··· 1 - import assert from 'node:assert' 2 - import { join } from 'pathe' 3 - import { defineConfig } from 'vite' 4 - 5 - const configRoot = join(__dirname, 'src') 6 - 7 - export default defineConfig({ 8 - root: configRoot, 9 - plugins: [ 10 - { 11 - name: 'root-checker', 12 - configResolved(config) { 13 - assert.equal(config.root, configRoot) 14 - }, 15 - }, 16 - ], 17 - })
-2
test/vite-node/package.json
··· 11 11 }, 12 12 "devDependencies": { 13 13 "@types/inquirer": "^9.0.3", 14 - "@vitest/test-dep1": "file:./deps/dep1", 15 - "@vitest/test-dep2": "file:./deps/dep2", 16 14 "execa": "^6.1.0", 17 15 "inquirer": "^9.2.7", 18 16 "vite-node": "workspace:*",
-12
test/vm-threads/package.json
··· 1 - { 2 - "name": "@vitest/test-vm-threads", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "jsdom": "latest", 10 - "vitest": "workspace:*" 11 - } 12 - }
-15
test/vm-threads/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - pool: 'vmThreads', 6 - css: { 7 - include: [/processed/], 8 - }, 9 - server: { 10 - deps: { 11 - external: [/src\/external/], 12 - }, 13 - }, 14 - }, 15 - })
-11
test/wasm-modules/package.json
··· 1 - { 2 - "name": "@vitest/test-wasm-modules", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "vitest": "workspace:*" 10 - } 11 - }
-19
test/wasm-modules/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - poolOptions: { 6 - threads: { 7 - execArgv: ['--experimental-wasm-modules'], 8 - }, 9 - forks: { 10 - execArgv: ['--experimental-wasm-modules'], 11 - }, 12 - }, 13 - server: { 14 - deps: { 15 - external: [/\.wasm$/, /\/wasm-bindgen-no-cyclic\/index_bg.js/], 16 - }, 17 - }, 18 - }, 19 - })
-13
test/web-worker/package.json
··· 1 - { 2 - "name": "@vitest/test-web-worker", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest", 7 - "coverage": "vitest run --coverage" 8 - }, 9 - "devDependencies": { 10 - "@vitest/web-worker": "workspace:*", 11 - "vitest": "workspace:*" 12 - } 13 - }
-1
test/web-worker/setup.ts
··· 1 - import '@vitest/web-worker'
-19
test/web-worker/vitest.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - setupFiles: [ 6 - './setup.ts', 7 - ], 8 - server: { 9 - deps: { 10 - external: [ 11 - /packages\/web-worker/, 12 - ], 13 - }, 14 - }, 15 - onConsoleLog(log) { 16 - return !log.includes('Failed to load') 17 - }, 18 - }, 19 - })
+12
test/workspaces-browser/globalTest.ts
··· 1 1 import { readFile } from 'node:fs/promises' 2 2 import assert from 'node:assert/strict' 3 3 4 + let teardownCalled = false 5 + 4 6 export async function teardown() { 7 + teardownCalled = true 5 8 const results = JSON.parse(await readFile('./results.json', 'utf-8')) 6 9 7 10 try { ··· 12 15 } 13 16 catch (err) { 14 17 console.error(err) 18 + // eslint-disable-next-line no-console 19 + console.dir(results, { depth: null }) 15 20 process.exit(1) 16 21 } 17 22 } 23 + 24 + process.on('beforeExit', () => { 25 + if (!teardownCalled) { 26 + console.error('teardown was not called') 27 + process.exitCode = 1 28 + } 29 + })
+2
test/workspaces/globalTest.ts
··· 42 42 } 43 43 catch (err) { 44 44 console.error(err) 45 + // eslint-disable-next-line no-console 46 + console.dir(results, { depth: null }) 45 47 process.exit(1) 46 48 } 47 49 }
-6
test/workspaces/vitest.config.ts
··· 1 1 import { defineConfig } from 'vitest/config' 2 2 import { cwdPlugin } from './cwdPlugin.js' 3 3 4 - if (process.env.TEST_WATCH) { 5 - // Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks 6 - process.stdin.isTTY = true 7 - process.stdin.setRawMode = () => process.stdin 8 - } 9 - 10 4 export default defineConfig({ 11 5 envPrefix: ['VITE_', 'CUSTOM_', 'ROOT_'], 12 6 plugins: [cwdPlugin('ROOT')],
+16
test/workspaces/vitest.config.watch.ts
··· 1 + import { defineConfig, mergeConfig } from 'vitest/config' 2 + import vitestConfig from './vitest.config' 3 + 4 + // Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks 5 + process.stdin.isTTY = true 6 + process.stdin.setRawMode = () => process.stdin 7 + 8 + export default mergeConfig(vitestConfig, defineConfig({ 9 + test: { 10 + coverage: { 11 + enabled: false, 12 + }, 13 + reporters: ['default'], 14 + globalSetup: undefined, 15 + }, 16 + }))
-12
test/ws-api/package.json
··· 1 - { 2 - "name": "@vitest/test-ws-api", 3 - "type": "module", 4 - "private": true, 5 - "scripts": { 6 - "test": "vitest" 7 - }, 8 - "devDependencies": { 9 - "@vitejs/plugin-basic-ssl": "^1.0.2", 10 - "vitest": "workspace:*" 11 - } 12 - }
-7
test/ws-api/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['tests/**/*.test.ts'], 6 - }, 7 - })
+1 -1
packages/vitest/src/suite.ts
··· 1 - export { getCurrentSuite, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner' 1 + export { getCurrentSuite, getCurrentTest, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner' 2 2 export { createChainable } from '@vitest/runner/utils' 3 3 export { getBenchFn, getBenchOptions } from './runtime/benchmark'
-35
test/bail/fixtures/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - import type { WorkspaceSpec } from 'vitest/node' 3 - 4 - class TestNameSequencer { 5 - async sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]> { 6 - return [...files].sort(([, filenameA], [, filenameB]) => { 7 - if (filenameA > filenameB) 8 - return 1 9 - 10 - if (filenameA < filenameB) 11 - return -1 12 - 13 - return 0 14 - }) 15 - } 16 - 17 - public async shard(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]> { 18 - return files 19 - } 20 - } 21 - 22 - export default defineConfig({ 23 - test: { 24 - reporters: 'verbose', 25 - cache: false, 26 - watch: false, 27 - sequence: { 28 - sequencer: TestNameSequencer, 29 - }, 30 - browser: { 31 - headless: true, 32 - name: 'chrome', 33 - }, 34 - }, 35 - })
-53
test/bail/test/bail.test.ts
··· 1 - import { type UserConfig, expect, test } from 'vitest' 2 - 3 - import { runVitest } from '../../test-utils' 4 - 5 - const configs: UserConfig[] = [] 6 - const pools: UserConfig[] = [{ pool: 'threads' }, { pool: 'forks' }, { pool: 'threads', poolOptions: { threads: { singleThread: true } } }] 7 - 8 - if (process.platform !== 'win32') 9 - pools.push({ browser: { enabled: true, name: 'chromium', provider: 'playwright' } }) 10 - 11 - for (const isolate of [true, false]) { 12 - for (const pool of pools) { 13 - configs.push({ 14 - ...pool, 15 - poolOptions: { 16 - threads: { 17 - ...pool.poolOptions?.threads, 18 - isolate, 19 - }, 20 - forks: { isolate }, 21 - }, 22 - }) 23 - } 24 - } 25 - 26 - for (const config of configs) { 27 - test(`should bail with "${JSON.stringify(config)}"`, async () => { 28 - const isParallel 29 - = (config.pool === 'threads' && config.poolOptions?.threads?.singleThread !== true) 30 - || (config.pool === 'forks' && config.poolOptions?.forks?.singleFork !== true) 31 - 32 - // THREADS here means that multiple tests are run parallel 33 - process.env.THREADS = isParallel ? 'true' : 'false' 34 - 35 - const { exitCode, stdout } = await runVitest({ 36 - root: './fixtures', 37 - bail: 1, 38 - ...config, 39 - }) 40 - 41 - expect(exitCode).toBe(1) 42 - expect(stdout).toMatch('✓ test/first.test.ts > 1 - first.test.ts - this should pass') 43 - expect(stdout).toMatch('× test/first.test.ts > 2 - first.test.ts - this should fail') 44 - 45 - // Cancelled tests should not be run 46 - expect(stdout).not.toMatch('test/first.test.ts > 3 - first.test.ts - this should be skipped') 47 - expect(stdout).not.toMatch('test/second.test.ts > 1 - second.test.ts - this should be skipped') 48 - expect(stdout).not.toMatch('test/second.test.ts > 2 - second.test.ts - this should be skipped') 49 - expect(stdout).not.toMatch('test/second.test.ts > 3 - second.test.ts - this should be skipped') 50 - }, { 51 - retry: config.browser?.enabled ? 3 : 0, 52 - }) 53 - }
-1
test/base/src/index.ts
··· 1 - export const foo = 'foo'
-10
test/base/test/mocking-with-base.spec.ts
··· 1 - import { expect, test, vi } from 'vitest' 2 - import { foo } from '../src' 3 - 4 - vi.mock('../src', () => ({ 5 - foo: 'baz', 6 - })) 7 - 8 - test('module is mocked', () => { 9 - expect(foo).toBe('baz') 10 - })
-36
test/browser/specs/filter.test.mjs
··· 1 - import assert from 'node:assert' 2 - import test from 'node:test' 3 - import { execa } from 'execa' 4 - 5 - test('filter', async () => { 6 - let result = execa( 7 - 'npx', 8 - [ 9 - 'vitest', 10 - 'run', 11 - 'test/basic.test.ts', 12 - '--testNamePattern', 13 - 'basic 2', 14 - '--browser.headless', 15 - '--reporter=verbose', 16 - ], 17 - { 18 - env: { 19 - CI: '1', 20 - NO_COLOR: '1', 21 - }, 22 - }, 23 - ) 24 - if (process.env.VITEST_BROWSER_DEBUG) { 25 - result.stderr.on('data', (data) => { 26 - process.stderr.write(data.toString()) 27 - }) 28 - result.stdout.on('data', (data) => { 29 - process.stdout.write(data.toString()) 30 - }) 31 - } 32 - result = await result 33 - assert.match(result.stdout, /✓ test\/basic.test.ts > basic 2/) 34 - assert.match(result.stdout, /Test Files {2}1 passed/) 35 - assert.match(result.stdout, /Tests {2}1 passed | 3 skipped/) 36 - })
+14
test/browser/specs/filter.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + import { runBrowserTests } from './utils' 3 + 4 + test('filter', async () => { 5 + const { stderr, stdout } = await runBrowserTests({ 6 + testNamePattern: 'basic 2', 7 + reporters: ['verbose'], 8 + }, ['test/basic.test.ts']) 9 + 10 + expect(stderr).toBe('') 11 + expect(stdout).toContain('✓ test/basic.test.ts > basic 2') 12 + expect(stdout).toContain('Test Files 1 passed') 13 + expect(stdout).toContain('Tests 1 passed | 3 skipped') 14 + })
-20
test/browser/specs/fix-4686.test.mjs
··· 1 - // fix #4686 2 - 3 - import assert from 'node:assert' 4 - import test from 'node:test' 5 - import runVitest from './run-vitest.mjs' 6 - 7 - const { 8 - stderr, 9 - browserResultJson, 10 - passedTests, 11 - failedTests, 12 - } = await runVitest(['--config', 'vitest.config-basepath.mts', 'basic.test.ts']) 13 - 14 - await test('tests run in presence of config.base', async () => { 15 - assert.ok(browserResultJson.testResults.length === 1, 'Not all the tests have been run') 16 - assert.ok(passedTests.length === 1, 'Some tests failed') 17 - assert.ok(failedTests.length === 0, 'Some tests have passed but should fail') 18 - 19 - assert.doesNotMatch(stderr, /Unhandled Error/, 'doesn\'t have any unhandled errors') 20 - })
+19
test/browser/specs/fix-4686.test.ts
··· 1 + // fix #4686 2 + 3 + import { expect, test } from 'vitest' 4 + import { runBrowserTests } from './utils' 5 + 6 + test('tests run in presence of config.base', async () => { 7 + const { stderr, failedTests, passedTests, browserResultJson } = await runBrowserTests( 8 + { 9 + config: './vitest.config-basepath.mts', 10 + }, 11 + ['test/basic.test.ts'], 12 + ) 13 + 14 + expect(browserResultJson.testResults).toHaveLength(1) 15 + expect(passedTests).toHaveLength(1) 16 + expect(failedTests).toHaveLength(0) 17 + 18 + expect(stderr).toBe('') 19 + })
-39
test/browser/specs/run-vitest.mjs
··· 1 - import { readFile } from 'node:fs/promises' 2 - import { execa } from 'execa' 3 - 4 - const browser = process.env.BROWSER || (process.env.PROVIDER === 'playwright' ? 'chromium' : 'chrome') 5 - 6 - export default async function runVitest(moreArgs = []) { 7 - const argv = ['vitest', '--run', `--browser.name=${browser}`] 8 - 9 - if (browser !== 'safari') 10 - argv.push('--browser.headless') 11 - 12 - const result = execa('npx', argv.concat(moreArgs), { 13 - env: { 14 - ...process.env, 15 - CI: 'true', 16 - NO_COLOR: 'true', 17 - }, 18 - reject: false, 19 - }) 20 - if (process.env.VITEST_BROWSER_DEBUG) { 21 - result.stderr.on('data', (data) => { 22 - process.stderr.write(data.toString()) 23 - }) 24 - result.stdout.on('data', (data) => { 25 - process.stdout.write(data.toString()) 26 - }) 27 - } 28 - const { stderr, stdout } = await result 29 - const browserResult = await readFile('./browser.json', 'utf-8') 30 - const browserResultJson = JSON.parse(browserResult) 31 - 32 - const getPassed = results => results.filter(result => result.status === 'passed' && !result.mesage) 33 - const getFailed = results => results.filter(result => result.status === 'failed') 34 - 35 - const passedTests = getPassed(browserResultJson.testResults) 36 - const failedTests = getFailed(browserResultJson.testResults) 37 - 38 - return { stderr, stdout, browserResultJson, passedTests, failedTests } 39 - }
-77
test/browser/specs/runner.test.mjs
··· 1 - import assert from 'node:assert' 2 - import test from 'node:test' 3 - import runVitest from './run-vitest.mjs' 4 - 5 - const cliArguments = [ 6 - ['not parallel', ['--no-browser.fileParallelism']], 7 - ['parallel', []], 8 - ] 9 - 10 - for (const [description, args] of cliArguments) { 11 - const { 12 - stderr, 13 - stdout, 14 - browserResultJson, 15 - passedTests, 16 - failedTests, 17 - } = await runVitest(args) 18 - 19 - await test(`[${description}] tests are actually running`, async () => { 20 - assert.equal(browserResultJson.testResults.length, 14, 'Not all the tests have been run') 21 - assert.equal(passedTests.length, 12, 'Some tests failed') 22 - assert.equal(failedTests.length, 2, 'Some tests have passed but should fail') 23 - 24 - assert.doesNotMatch(stderr, /has been externalized for browser compatibility/, 'doesn\'t have any externalized modules') 25 - assert.doesNotMatch(stderr, /Unhandled Error/, 'doesn\'t have any unhandled errors') 26 - }) 27 - 28 - await test(`[${description}] correctly prints error`, () => { 29 - assert.match(stderr, /expected 1 to be 2/, 'prints failing error') 30 - assert.match(stderr, /- 2\s+\+ 1/, 'prints failing diff') 31 - assert.match(stderr, /Expected to be/, 'prints \`Expected to be\`') 32 - assert.match(stderr, /But got/, 'prints \`But got\`') 33 - }) 34 - 35 - await test(`[${description}] logs are redirected to stdout`, async () => { 36 - assert.match(stdout, /stdout | test\/logs.test.ts > logging to stdout/) 37 - assert.match(stdout, /hello from console.log/, 'prints console.log') 38 - assert.match(stdout, /hello from console.info/, 'prints console.info') 39 - assert.match(stdout, /hello from console.debug/, 'prints console.debug') 40 - assert.match(stdout, /{ hello: 'from dir' }/, 'prints console.dir') 41 - assert.match(stdout, /{ hello: 'from dirxml' }/, 'prints console.dixml') 42 - // safari logs the stack files with @https://... 43 - assert.match(stdout, /hello from console.trace\s+(\w+|@)/, 'prints console.trace') 44 - assert.match(stdout, /dom <div \/>/, 'prints dom') 45 - assert.match(stdout, /default: 1/, 'prints first default count') 46 - assert.match(stdout, /default: 2/, 'prints second default count') 47 - assert.match(stdout, /default: 3/, 'prints third default count') 48 - assert.match(stdout, /count: 1/, 'prints first custom count') 49 - assert.match(stdout, /count: 2/, 'prints second custom count') 50 - assert.match(stdout, /count: 3/, 'prints third custom count') 51 - assert.match(stdout, /default: [\d.]+ ms/, 'prints default time') 52 - assert.match(stdout, /time: [\d.]+ ms/, 'prints custom time') 53 - }) 54 - 55 - await test(`[${description}] logs are redirected to stderr`, async () => { 56 - assert.match(stderr, /stderr | test\/logs.test.ts > logging to stderr/) 57 - assert.match(stderr, /hello from console.error/, 'prints console.log') 58 - assert.match(stderr, /hello from console.warn/, 'prints console.info') 59 - assert.match(stderr, /Timer "invalid timeLog" does not exist/, 'prints errored timeLog') 60 - assert.match(stderr, /Timer "invalid timeEnd" does not exist/, 'prints errored timeEnd') 61 - }) 62 - 63 - await test(`[${description}] stack trace points to correct file in every browser`, () => { 64 - // dependeing on the browser it references either `.toBe()` or `expect()` 65 - assert.match(stderr, /test\/failing.test.ts:4:(12|17)/, 'prints stack trace') 66 - }) 67 - 68 - await test(`[${description}] popup apis should log a warning`, () => { 69 - assert.ok(stderr.includes('Vitest encountered a \`alert\("test"\)\`'), 'prints warning for alert') 70 - assert.ok(stderr.includes('Vitest encountered a \`confirm\("test"\)\`'), 'prints warning for confirm') 71 - assert.ok(stderr.includes('Vitest encountered a \`prompt\("test"\)\`'), 'prints warning for prompt') 72 - }) 73 - 74 - await test(`[${description}] snapshot inaccessible file debuggability`, () => { 75 - assert.ok(stdout.includes('Access denied to "/inaccesible/path".'), 'file security enforcement explained') 76 - }) 77 - }
+86
test/browser/specs/runner.test.ts
··· 1 + import { beforeAll, describe, expect, test } from 'vitest' 2 + import { runBrowserTests } from './utils' 3 + 4 + describe.each([ 5 + ['non parallel', false], 6 + ['parallel', true], 7 + ])('[%s] running browser tests', async (description, fileParallelism) => { 8 + let stderr: string 9 + let stdout: string 10 + let browserResultJson: any 11 + let passedTests: any[] 12 + let failedTests: any[] 13 + 14 + beforeAll(async () => { 15 + ({ 16 + stderr, 17 + stdout, 18 + browserResultJson, 19 + passedTests, 20 + failedTests, 21 + } = await runBrowserTests({ 22 + browser: { 23 + fileParallelism, 24 + }, 25 + })) 26 + }) 27 + 28 + test(`[${description}] tests are actually running`, () => { 29 + expect(browserResultJson.testResults).toHaveLength(14) 30 + expect(passedTests).toHaveLength(12) 31 + expect(failedTests).toHaveLength(2) 32 + 33 + expect(stderr).not.toContain('has been externalized for browser compatibility') 34 + expect(stderr).not.toContain('Unhandled Error') 35 + }) 36 + 37 + test(`[${description}] correctly prints error`, () => { 38 + expect(stderr).toContain('expected 1 to be 2') 39 + expect(stderr).toMatch(/- 2\s+\+ 1/) 40 + expect(stderr).toContain('Expected to be') 41 + expect(stderr).toContain('But got') 42 + }) 43 + 44 + test(`[${description}] logs are redirected to stdout`, () => { 45 + expect(stdout).toContain('stdout | test/logs.test.ts > logging to stdout') 46 + expect(stdout).toContain('hello from console.log') 47 + expect(stdout).toContain('hello from console.info') 48 + expect(stdout).toContain('hello from console.debug') 49 + expect(stdout).toContain('{ hello: \'from dir\' }') 50 + expect(stdout).toContain('{ hello: \'from dirxml\' }') 51 + // safari logs the stack files with @https://... 52 + expect(stdout).toMatch(/hello from console.trace\s+(\w+|@)/) 53 + expect(stdout).toContain('dom <div />') 54 + expect(stdout).toContain('default: 1') 55 + expect(stdout).toContain('default: 2') 56 + expect(stdout).toContain('default: 3') 57 + expect(stdout).toContain('count: 1') 58 + expect(stdout).toContain('count: 2') 59 + expect(stdout).toContain('count: 3') 60 + expect(stdout).toMatch(/default: [\d.]+ ms/) 61 + expect(stdout).toMatch(/time: [\d.]+ ms/) 62 + }) 63 + 64 + test(`[${description}] logs are redirected to stderr`, () => { 65 + expect(stderr).toContain('stderr | test/logs.test.ts > logging to stderr') 66 + expect(stderr).toContain('hello from console.error') 67 + expect(stderr).toContain('hello from console.warn') 68 + expect(stderr).toContain('Timer "invalid timeLog" does not exist') 69 + expect(stderr).toContain('Timer "invalid timeEnd" does not exist') 70 + }) 71 + 72 + test(`[${description}] stack trace points to correct file in every browser`, () => { 73 + // dependeing on the browser it references either `.toBe()` or `expect()` 74 + expect(stderr).toMatch(/test\/failing.test.ts:4:(12|17)/) 75 + }) 76 + 77 + test(`[${description}] popup apis should log a warning`, () => { 78 + expect(stderr).toContain('Vitest encountered a `alert("test")`') 79 + expect(stderr).toContain('Vitest encountered a `confirm("test")`') 80 + expect(stderr).toContain('Vitest encountered a `prompt("test")`') 81 + }) 82 + 83 + test(`[${description}] snapshot inaccessible file debuggability`, () => { 84 + expect(stderr).toContain('Access denied to "/inaccesible/path".') 85 + }) 86 + })
-26
test/browser/specs/server-url.test.mjs
··· 1 - import assert from 'node:assert' 2 - import test from 'node:test' 3 - import { execa } from 'execa' 4 - 5 - test('server-url http', async () => { 6 - const result = await execa('npx', ['vitest', 'run', '--root=./fixtures/server-url', '--browser.headless'], { 7 - env: { 8 - CI: '1', 9 - NO_COLOR: '1', 10 - }, 11 - }) 12 - assert.match(result.stdout, /Browser runner started at http:\/\/localhost:5173\//) 13 - assert.match(result.stdout, /Test Files {2}1 passed/) 14 - }) 15 - 16 - test('server-url https', async () => { 17 - const result = await execa('npx', ['vitest', 'run', '--root=./fixtures/server-url', '--browser.headless'], { 18 - env: { 19 - CI: '1', 20 - NO_COLOR: '1', 21 - TEST_HTTPS: '1', 22 - }, 23 - }) 24 - assert.match(result.stdout, /Browser runner started at https:\/\/localhost:5173\//) 25 - assert.match(result.stdout, /Test Files {2}1 passed/) 26 - })
+24
test/browser/specs/server-url.test.ts
··· 1 + import { afterEach, expect, test } from 'vitest' 2 + import { runBrowserTests } from './utils' 3 + 4 + afterEach(() => { 5 + delete process.env.TEST_HTTPS 6 + }) 7 + 8 + test('server-url http', async () => { 9 + const { stdout, stderr } = await runBrowserTests({ 10 + root: './fixtures/server-url', 11 + }) 12 + expect(stderr).toBe('') 13 + expect(stdout).toContain('Browser runner started at http://localhost:5173/') 14 + }) 15 + 16 + test('server-url https', async () => { 17 + process.env.TEST_HTTPS = '1' 18 + const { stdout, stderr } = await runBrowserTests({ 19 + root: './fixtures/server-url', 20 + }) 21 + expect(stderr).toBe('') 22 + expect(stdout).toContain('Browser runner started at https://localhost:5173/') 23 + expect(stdout).toContain('Test Files 1 passed') 24 + })
-70
test/browser/specs/update-snapshot.test.mjs
··· 1 - import assert from 'node:assert' 2 - import fs from 'node:fs' 3 - import test from 'node:test' 4 - import { startVitest } from 'vitest/node' 5 - 6 - let vitest 7 - 8 - test.after(async () => { 9 - await vitest?.close() 10 - }) 11 - 12 - test('update snapshot', async () => { 13 - // setup wrong snapshot value 14 - const snapshotPath = './fixtures/update-snapshot/__snapshots__/basic.test.ts.snap' 15 - await editFile(snapshotPath, data => data.replace('`1`', '`2`')) 16 - 17 - // run vitest watch mode 18 - const result = await wrapExit(() => startVitest('test', [], { 19 - watch: true, 20 - root: './fixtures/update-snapshot', 21 - reporters: ['tap-flat'], // use simple reporter to not pollute stdout 22 - browser: { headless: true }, 23 - })) 24 - vitest = result.value 25 - assert.ok(vitest) 26 - 27 - // test fails 28 - assert.equal(result.exitCode, 1) 29 - assert.equal(vitest.state.getFiles()[0].result.state, 'fail') 30 - 31 - // updateSnapshot API to simulate "u" commmand 32 - await vitest.updateSnapshot() 33 - 34 - // verify snapshot value is updated 35 - const snapshotData = await fs.promises.readFile(snapshotPath, 'utf-8') 36 - assert.match(snapshotData, /`1`/) 37 - 38 - // test passes 39 - assert.equal(vitest.state.getFiles()[0].result.state, 'pass') 40 - }) 41 - 42 - /** 43 - * @param {string} filepath 44 - * @param {(data: string) => string} edit 45 - */ 46 - async function editFile(filepath, edit) { 47 - const data = await fs.promises.readFile(filepath, 'utf-8') 48 - await fs.promises.writeFile(filepath, edit(data)) 49 - } 50 - 51 - /** 52 - * run function and return mutated exitCode while preserving current exitCode 53 - * @param {() => any} f 54 - */ 55 - async function wrapExit(f) { 56 - const prevExitCode = process.exitCode 57 - const prevExit = process.exit 58 - process.exit = () => {} 59 - /** @type {{ value?: any, exitCode?: number }} */ 60 - const result = {} 61 - try { 62 - result.value = await f() 63 - } 64 - finally { 65 - result.exitCode = process.exitCode 66 - process.exitCode = prevExitCode 67 - process.exit = prevExit 68 - } 69 - return result 70 - }
+36
test/browser/specs/update-snapshot.test.ts
··· 1 + import fs from 'node:fs' 2 + import { expect, onTestFinished, test } from 'vitest' 3 + import { editFile } from '../../test-utils' 4 + import { runBrowserTests } from './utils' 5 + 6 + test('update snapshot', async () => { 7 + // setup wrong snapshot value 8 + const snapshotPath = './fixtures/update-snapshot/__snapshots__/basic.test.ts.snap' 9 + editFile(snapshotPath, data => data.replace('`1`', '`2`')) 10 + 11 + // run vitest watch mode 12 + const { exitCode, ctx: vitest } = await runBrowserTests({ 13 + watch: true, 14 + root: './fixtures/update-snapshot', 15 + reporters: ['tap-flat'], // use simple reporter to not pollute stdout 16 + browser: { headless: true }, 17 + }) 18 + onTestFinished(() => vitest.close()) 19 + 20 + // test fails 21 + expect(exitCode).toBe(1) 22 + 23 + const files = vitest.state.getFiles() 24 + expect(files).toHaveLength(1) 25 + expect(files[0].result.state).toBe('fail') 26 + 27 + // updateSnapshot API to simulate "u" commmand 28 + await vitest.updateSnapshot() 29 + 30 + // verify snapshot value is updated 31 + const snapshotData = await fs.promises.readFile(snapshotPath, 'utf-8') 32 + expect(snapshotData).toContain('`1`') 33 + 34 + // test passes 35 + expect(vitest.state.getFiles()[0].result.state).toBe('pass') 36 + })
+28
test/browser/specs/utils.ts
··· 1 + import { readFile } from 'node:fs/promises' 2 + import type { UserConfig } from 'vitest' 3 + import { runVitest } from '../../test-utils' 4 + 5 + const browser = process.env.BROWSER || (process.env.PROVIDER !== 'playwright' ? 'chromium' : 'chrome') 6 + 7 + export async function runBrowserTests(config?: Omit<UserConfig, 'browser'> & { browser?: Partial<UserConfig['browser']> }, include?: string[]) { 8 + const result = await runVitest({ 9 + watch: false, 10 + reporters: 'none', 11 + ...config, 12 + browser: { 13 + headless: browser !== 'safari', 14 + ...config?.browser, 15 + } as UserConfig['browser'], 16 + }, include) 17 + 18 + const browserResult = await readFile('./browser.json', 'utf-8') 19 + const browserResultJson = JSON.parse(browserResult) 20 + 21 + const getPassed = results => results.filter(result => result.status === 'passed' && !result.mesage) 22 + const getFailed = results => results.filter(result => result.status === 'failed') 23 + 24 + const passedTests = getPassed(browserResultJson.testResults) 25 + const failedTests = getFailed(browserResultJson.testResults) 26 + 27 + return { ...result, browserResultJson, passedTests, failedTests } 28 + }
-36
test/changed/tests/forceRerunTrigger.test.ts
··· 1 - import { unlink, writeFile } from 'node:fs' 2 - import { join } from 'node:path' 3 - import { beforeEach, describe, expect, it } from 'vitest' 4 - 5 - import { runVitest } from '../../test-utils' 6 - 7 - const fileName = 'fixtures/related/rerun.temp' 8 - 9 - describe('forceRerunTrigger', () => { 10 - async function run() { 11 - return runVitest({ 12 - root: join(process.cwd(), 'fixtures/related'), 13 - include: ['related.test.ts'], 14 - forceRerunTriggers: ['**/rerun.temp/**'], 15 - changed: true, 16 - }) 17 - } 18 - 19 - beforeEach(async () => { 20 - unlink(fileName, () => {}) 21 - }) 22 - 23 - it('should run the whole test suite if file exists', async () => { 24 - writeFile(fileName, '', () => {}) 25 - const { stdout, stderr } = await run() 26 - expect(stderr).toBe('') 27 - expect(stdout).toContain('1 passed') 28 - expect(stdout).toContain('related.test.ts') 29 - expect(stdout).not.toContain('not-related.test.ts') 30 - }) 31 - 32 - it('should run no tests if file does not exist', async () => { 33 - const { stdout } = await run() 34 - expect(stdout).toContain('No test files found, exiting with code 0') 35 - }) 36 - })
-18
test/changed/tests/related.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - 3 - import { runVitest } from '../../test-utils' 4 - 5 - it('related correctly runs only related tests', async () => { 6 - const { stdout, stderr } = await runVitest({ 7 - related: 'src/sourceA.ts', 8 - root: './fixtures/related', 9 - globals: true, 10 - }) 11 - 12 - expect(stderr).toBe('') 13 - expect(stdout).toContain('3 passed') 14 - expect(stdout).toContain('related.test.ts') 15 - expect(stdout).toContain('deep-related-imports.test.ts') 16 - expect(stdout).toContain('deep-related-exports.test.ts') 17 - expect(stdout).not.toContain('not-related.test.ts') 18 - })
-27
test/changed/tests/workspaceRelated.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - 3 - import { editFile, resolvePath, runVitest } from '../../test-utils' 4 - 5 - it('doesn\'t run any test in a workspace because there are no changes', async () => { 6 - const { stdout } = await runVitest({ 7 - changed: true, 8 - root: './fixtures/workspace', 9 - }) 10 - 11 - expect(stdout).toContain('No test files found, exiting with code 0') 12 - }) 13 - 14 - // Fixes #4674 15 - it('related correctly runs only related tests inside a workspace', async () => { 16 - editFile(resolvePath(import.meta.url, '../fixtures/workspace/packages/packageA/index.js'), content => `${content}\n`) 17 - 18 - const { stdout, stderr } = await runVitest({ 19 - changed: true, 20 - root: './fixtures/workspace', 21 - }) 22 - 23 - expect(stderr).toBe('') 24 - expect(stdout).toContain('1 passed') 25 - expect(stdout).toContain('packageA') 26 - expect(stdout).not.toContain('packageB') 27 - })
-8
test/cjs/src/default-function.cjs
··· 1 - 'use strict' 2 - 3 - function format() { 4 - return '' 5 - } 6 - 7 - module.exports = format 8 - module.exports.default = format
-3
test/cjs/src/default-function.d.cts
··· 1 - declare function format(): string 2 - 3 - export default format
-2
test/cjs/src/other.cjs
··· 1 - 'use strict' 2 - exports.default = 2
-5
test/cjs/src/other.d.cts
··· 1 - declare const defaultExports: { 2 - default: number 3 - } 4 - 5 - export default defaultExports
-7
test/cjs/src/prototype.cjs
··· 1 - exports.test = () => { 2 - // eslint-disable-next-line no-prototype-builtins 3 - return exports.hasOwnProperty('test') 4 - } 5 - exports.getPrototype = () => { 6 - return Object.getPrototypeOf(exports) 7 - }
-2
test/cjs/src/prototype.d.cts
··· 1 - export const test: () => boolean 2 - export const getPrototype: () => any
-12
test/cjs/test/fs-extra.test.ts
··· 1 - import fs, { existsSync } from 'fs-extra' 2 - import { describe, expect, it } from 'vitest' 3 - 4 - describe('fs-extra', () => { 5 - it('default export', () => { 6 - expect(fs.existsSync('test/fs-extra.test.ts')).toBe(true) 7 - }) 8 - 9 - it('named export', () => { 10 - expect(existsSync('test/fs-extra.test.ts')).toBe(true) 11 - }) 12 - })
-13
test/cjs/test/function-default.test.ts
··· 1 - import { describe, expect, it } from 'vitest' 2 - import format from '../src/default-function.cjs' 3 - 4 - describe('correctly puts default on default', () => { 5 - it('works on default function', () => { 6 - expect(format()).toBe('') 7 - }) 8 - 9 - it('works on nested default function', () => { 10 - // @ts-expect-error types defined only default 11 - expect(format.default).toBeUndefined() 12 - }) 13 - })
-9
test/cjs/test/history.test.ts
··· 1 - import { createMemoryHistory } from 'history' 2 - import { describe, expect, it } from 'vitest' 3 - 4 - describe('history', () => { 5 - it('should work', () => { 6 - const history = createMemoryHistory() 7 - expect(history.location.pathname).toBe('/') 8 - }) 9 - })
-24
test/cjs/test/interpret-default.test.tsx
··· 1 - import { expect, it } from 'vitest' 2 - import { format } from 'prettier' 3 - import givens from 'givens' 4 - import tempDir from 'temp-dir' 5 - import _, { isString } from 'lodash' 6 - 7 - it('prettier', () => { 8 - expect(format('const a : A = \'t\'', { parser: 'typescript' }).trim()) 9 - .toEqual('const a: A = "t";'.trim()) 10 - }) 11 - 12 - it('lodash', () => { 13 - expect(typeof _.isString).toBe('function') 14 - expect(typeof isString).toBe('function') 15 - }) 16 - 17 - it('has nested default', () => { 18 - expect(typeof givens).toBe('function') 19 - expect(givens.name).toBe('getGiven') 20 - }) 21 - 22 - it('nested default is not an object', () => { 23 - expect(typeof tempDir).toBe('string') 24 - })
-8
test/cjs/test/prototype.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - import * as cjsExports from '../src/prototype.cjs' 3 - 4 - it('has object prototype', () => { 5 - expect(cjsExports.getPrototype()).toBe(Object.prototype) 6 - expect(() => cjsExports.test()).not.toThrow() 7 - expect(cjsExports.test()).toBe(true) 8 - })
+2
test/cli/fixtures/vitest.config.js
··· 1 + // an empty config so the main one is not accidentaly inherited by the tests 2 + export default {}
+22
test/cli/test/custom-pool.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + import { runVitest } from '../../test-utils' 3 + 4 + test('can run custom pools with Vitest', async () => { 5 + const vitest = await runVitest({ 6 + root: './fixtures/custom-pool', 7 + reporters: ['basic'], 8 + }) 9 + 10 + expect(vitest.stderr).toMatchInlineSnapshot(` 11 + "[pool] printing: options are respected 12 + [pool] array option [ 1, 2, 3 ] 13 + [pool] running tests for custom-pool-test in /fixtures/custom-pool/tests/custom-not-run.spec.ts 14 + [pool] custom pool is closed! 15 + " 16 + `) 17 + 18 + expect(vitest.stdout).toContain('✓ |custom-pool-test| tests/custom-not-run.spec.ts') 19 + expect(vitest.stdout).toContain('✓ |custom-pool-test| tests/custom-run.threads.spec.ts') 20 + expect(vitest.stdout).toContain('Test Files 2 passed') 21 + expect(vitest.stdout).toContain('Tests 2 passed') 22 + })
+10
test/cli/test/dotted-files.test.ts
··· 1 + import { resolve } from 'node:path' 2 + import { expect, it } from 'vitest' 3 + import { runVitestCli } from '../../test-utils' 4 + 5 + it('run tests even though they are inside the .cache directory', async () => { 6 + const { stderr } = await runVitestCli({ 7 + cwd: resolve(process.cwd(), 'fixtures/dotted-files/.cache/projects/test'), 8 + }, '--no-watch') 9 + expect(stderr).toBe('') 10 + })
-14
test/cli/test/exclude.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - import { runVitest } from '../../test-utils' 4 - 5 - test('should still test math.test.ts', async () => { 6 - const { stderr, stdout } = await runVitest({ 7 - config: 'fixtures/exclude/vitest.exclude.config.ts', 8 - exclude: ['fixtures/exclude/string.test.ts'], 9 - }) 10 - 11 - expect(stdout).toContain(`✓ fixtures/exclude/math.test.ts`) 12 - expect(stdout).not.toContain(`string.test.ts`) 13 - expect(stderr).toBe('') 14 - })
+61
test/cli/test/expect-soft.test.ts
··· 1 + import { resolve } from 'node:path' 2 + import type { UserConfig } from 'vitest' 3 + import { describe, expect, test } from 'vitest' 4 + import { getCurrentTest } from 'vitest/suite' 5 + import { runVitest } from '../../test-utils' 6 + 7 + describe('expect.soft', () => { 8 + const run = (config?: UserConfig) => runVitest({ 9 + root: resolve('./fixtures/expect-soft'), 10 + include: ['expects/soft.test.ts'], 11 + setupFiles: [], 12 + testNamePattern: getCurrentTest()?.name, 13 + testTimeout: 4000, 14 + ...config, 15 + }, ['soft']) 16 + 17 + test('basic', async () => { 18 + const { stderr } = await run() 19 + expect.soft(stderr).toContain('AssertionError: expected 1 to be 2') 20 + expect.soft(stderr).toContain('AssertionError: expected 2 to be 3') 21 + }) 22 + 23 + test('promise', async () => { 24 + const { stderr } = await run() 25 + expect.soft(stderr).toContain('AssertionError: expected 2 to be 3') 26 + expect.soft(stderr).toContain('AssertionError: expected 1 to be 2') 27 + }) 28 + 29 + test('with expect', async () => { 30 + const { stderr } = await run() 31 + expect.soft(stderr).toContain('AssertionError: expected 1 to deeply equal 2') 32 + expect.soft(stderr).toContain('AssertionError: expected 10 to deeply equal 20') 33 + expect.soft(stderr).not.toContain('AssertionError: expected 2 to deeply equal 3') 34 + }) 35 + 36 + test('with expect.extend', async () => { 37 + const { stderr } = await run() 38 + expect.soft(stderr).toContain('AssertionError: expected 1 to deeply equal 2') 39 + expect.soft(stderr).toContain('Error: expected 3 to be divisible by 4') 40 + expect.soft(stderr).toContain('AssertionError: expected 5 to deeply equal 6') 41 + }) 42 + 43 + test('passed', async () => { 44 + const { stdout } = await run() 45 + expect.soft(stdout).toContain('soft.test.ts > passed') 46 + }) 47 + 48 + test('retry will passed', async () => { 49 + const { stdout } = await run() 50 + expect.soft(stdout).toContain('soft.test.ts > retry will passed') 51 + }) 52 + 53 + test('retry will failed', async () => { 54 + const { stderr } = await run() 55 + expect.soft(stderr).toContain('AssertionError: expected 1 to be 4') 56 + expect.soft(stderr).toContain('AssertionError: expected 2 to be 5') 57 + expect.soft(stderr).toContain('AssertionError: expected 3 to be 4') 58 + expect.soft(stderr).toContain('AssertionError: expected 4 to be 5') 59 + expect.soft(stderr).toContain('4/4') 60 + }) 61 + })
+48
test/cli/test/fails.test.ts
··· 1 + import { resolve } from 'pathe' 2 + import fg from 'fast-glob' 3 + import { expect, it } from 'vitest' 4 + 5 + import { runVitest } from '../../test-utils' 6 + 7 + const root = resolve(__dirname, '../fixtures/fails') 8 + const files = await fg('**/*.test.ts', { cwd: root, dot: true }) 9 + 10 + it.each(files)('should fail %s', async (file) => { 11 + const { stderr } = await runVitest({ root }, [file]) 12 + 13 + expect(stderr).toBeTruthy() 14 + const msg = String(stderr) 15 + .split(/\n/g) 16 + .reverse() 17 + .filter(i => i.includes('Error: ') && !i.includes('Command failed') && !i.includes('stackStr') && !i.includes('at runTest')) 18 + .map(i => i.trim().replace(root, '<rootDir>'), 19 + ).join('\n') 20 + expect(msg).toMatchSnapshot(file) 21 + }, 30_000) 22 + 23 + it('should report coverage when "coverag.reportOnFailure: true" and tests fail', async () => { 24 + const { stdout } = await runVitest({ 25 + root, 26 + coverage: { 27 + enabled: true, 28 + provider: 'istanbul', 29 + reportOnFailure: true, 30 + reporter: ['text'], 31 + }, 32 + }, [files[0]]) 33 + 34 + expect(stdout).toMatch('Coverage report from istanbul') 35 + }) 36 + 37 + it('should not report coverage when "coverag.reportOnFailure" has default value and tests fail', async () => { 38 + const { stdout } = await runVitest({ 39 + root, 40 + coverage: { 41 + enabled: true, 42 + provider: 'istanbul', 43 + reporter: ['text'], 44 + }, 45 + }, [files[0]]) 46 + 47 + expect(stdout).not.toMatch('Coverage report from istanbul') 48 + })
+76
test/cli/test/git-changed.test.ts
··· 1 + import { join } from 'node:path' 2 + import { describe, expect, it } from 'vitest' 3 + 4 + import { createFile, editFile, resolvePath, runVitest } from '../../test-utils' 5 + 6 + const fileName = 'fixtures/git-changed/related/rerun.temp' 7 + 8 + // NOTE: if there are any changes in fixtures/git-changed, 9 + // most tests will probably fail 10 + 11 + describe('forceRerunTrigger', () => { 12 + async function run() { 13 + return runVitest({ 14 + root: join(process.cwd(), 'fixtures/git-changed/related'), 15 + include: ['related.test.ts'], 16 + forceRerunTriggers: ['**/rerun.temp/**'], 17 + changed: true, 18 + }) 19 + } 20 + 21 + it('should run the whole test suite if file exists', async () => { 22 + createFile(fileName, '') 23 + const { stdout, stderr } = await run() 24 + expect(stderr).toBe('') 25 + expect(stdout).toContain('1 passed') 26 + expect(stdout).toContain('related.test.ts') 27 + expect(stdout).not.toContain('not-related.test.ts') 28 + }) 29 + 30 + it('should run no tests if file does not exist', async () => { 31 + const { stdout } = await run() 32 + expect(stdout).toContain('No test files found, exiting with code 0') 33 + }) 34 + }) 35 + 36 + it('related correctly runs only related tests', async () => { 37 + const { stdout, stderr } = await runVitest({ 38 + related: 'src/sourceA.ts', 39 + root: './fixtures/git-changed/related', 40 + globals: true, 41 + }) 42 + 43 + expect(stderr).toBe('') 44 + expect(stdout).toContain('3 passed') 45 + expect(stdout).toContain('related.test.ts') 46 + expect(stdout).toContain('deep-related-imports.test.ts') 47 + expect(stdout).toContain('deep-related-exports.test.ts') 48 + expect(stdout).not.toContain('not-related.test.ts') 49 + }) 50 + 51 + it('doesn\'t run any test in a workspace because there are no changes', async () => { 52 + const { stdout } = await runVitest({ 53 + changed: true, 54 + root: './fixtures/git-changed/workspace', 55 + }) 56 + 57 + expect(stdout).toContain('No test files found, exiting with code 0') 58 + }) 59 + 60 + // Fixes #4674 61 + it('related correctly runs only related tests inside a workspace', async () => { 62 + editFile( 63 + resolvePath(import.meta.url, '../fixtures/git-changed/workspace/packages/packageA/index.js'), 64 + content => `${content}\n`, 65 + ) 66 + 67 + const { stdout, stderr } = await runVitest({ 68 + changed: true, 69 + root: './fixtures/git-changed/workspace', 70 + }) 71 + 72 + expect(stderr).toBe('') 73 + expect(stdout).toContain('1 passed') 74 + expect(stdout).toContain('packageA') 75 + expect(stdout).not.toContain('packageB') 76 + })
+17
test/cli/test/global-setup-fail.test.ts
··· 1 + import { resolve } from 'pathe' 2 + import { expect, it } from 'vitest' 3 + 4 + import { runVitest } from '../../test-utils' 5 + 6 + it('should fail', async () => { 7 + const root = resolve(__dirname, '../fixtures/global-setup-fail') 8 + const { stderr } = await runVitest({ root }) 9 + 10 + expect(stderr).toBeTruthy() 11 + const msg = String(stderr) 12 + .split(/\n/g) 13 + .reverse() 14 + .find(i => i.includes('Error: ')) 15 + ?.trim() 16 + expect(msg).toBe('Error: error') 17 + }, 50000)
+92
test/cli/test/inspect.test.ts
··· 1 + import type { InspectorNotification } from 'node:inspector' 2 + import { expect, test } from 'vitest' 3 + import WebSocket from 'ws' 4 + 5 + import { isWindows } from '../../../packages/vite-node/src/utils' 6 + import { runVitestCli } from '../../test-utils' 7 + 8 + type Message = Partial<InspectorNotification<any>> 9 + 10 + test.skipIf(isWindows)('--inspect-brk stops at test file', async () => { 11 + const { vitest, waitForClose } = await runVitestCli( 12 + '--root', 13 + 'fixtures/inspect', 14 + '--inspect-brk', 15 + '9232', 16 + '--no-file-parallelism', 17 + ) 18 + 19 + await vitest.waitForStderr('Debugger listening on ') 20 + const url = vitest.stderr.split('\n')[0].replace('Debugger listening on ', '') 21 + 22 + const { receive, send } = await createChannel(url) 23 + 24 + send({ method: 'Debugger.enable' }) 25 + send({ method: 'Runtime.enable' }) 26 + await receive('Runtime.executionContextCreated') 27 + 28 + const paused = receive('Debugger.paused') 29 + send({ method: 'Runtime.runIfWaitingForDebugger' }) 30 + 31 + const { params } = await paused 32 + const scriptId = params.callFrames[0].functionLocation.scriptId 33 + 34 + // Verify that debugger paused on test file 35 + const response = receive() 36 + send({ method: 'Debugger.getScriptSource', params: { scriptId } }) 37 + const { result } = await response as any 38 + 39 + expect(result.scriptSource).toContain('test("sum", () => {') 40 + expect(result.scriptSource).toContain('expect(1 + 1).toBe(2)') 41 + 42 + send({ method: 'Debugger.resume' }) 43 + 44 + await vitest.waitForStdout('Test Files 1 passed (1)') 45 + await waitForClose() 46 + }) 47 + 48 + async function createChannel(url: string) { 49 + const ws = new WebSocket(url) 50 + 51 + let id = 1 52 + let receiver = defer() 53 + 54 + ws.onerror = receiver.reject 55 + ws.onmessage = (message) => { 56 + const response = JSON.parse(message.data.toString()) 57 + receiver.resolve(response) 58 + } 59 + 60 + async function receive(filter?: string) { 61 + const message = await receiver.promise 62 + receiver = defer() 63 + 64 + if (filter && message.method !== filter) 65 + return receive(filter) 66 + 67 + return message 68 + } 69 + 70 + function send(message: Message) { 71 + ws.send(JSON.stringify({ ...message, id: id++ })) 72 + } 73 + 74 + await new Promise(r => ws.on('open', r)) 75 + 76 + return { receive, send } 77 + } 78 + 79 + function defer(): { 80 + promise: Promise<Message> 81 + resolve: (response: Message) => void 82 + reject: (error: unknown) => void 83 + } { 84 + const pr = {} as ReturnType<typeof defer> 85 + 86 + pr.promise = new Promise((resolve, reject) => { 87 + pr.resolve = resolve 88 + pr.reject = reject 89 + }) 90 + 91 + return pr 92 + }
+37
test/cli/test/network-imports.test.ts
··· 1 + import { expect, it } from 'vitest' 2 + import { runVitest } from '../../test-utils' 3 + 4 + const config = { 5 + poolOptions: { 6 + threads: { 7 + execArgv: ['--experimental-network-imports'], 8 + }, 9 + forks: { 10 + execArgv: ['--experimental-network-imports'], 11 + }, 12 + // not supported? 13 + // FAIL test/basic.test.ts [ test/basic.test.ts ] 14 + // Error: ENOENT: no such file or directory, open 'http://localhost:9602/slash@3.0.0.js' 15 + // ❯ Object.openSync node:fs:596:3 16 + // ❯ readFileSync node:fs:464:35 17 + vmThreads: { 18 + execArgv: ['--experimental-network-imports'], 19 + }, 20 + }, 21 + // let vite serve public/slash@3.0.0.js 22 + api: 9602, 23 + } 24 + 25 + it.each([ 26 + 'threads', 27 + 'forks', 28 + // 'vmThreads', 29 + ])('importing from network in %s', async (pool) => { 30 + const { stderr, exitCode } = await runVitest({ 31 + ...config, 32 + root: './fixtures/network-imports', 33 + pool, 34 + }) 35 + expect(stderr).toBe('') 36 + expect(exitCode).toBe(0) 37 + })
-21
test/cli/test/project.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - import { runVitest } from '../../test-utils' 3 - 4 - test.each([ 5 - { pattern: 'project_1', expected: ['project_1'] }, 6 - { pattern: '*', expected: ['project_1', 'project_2', 'space_1'] }, 7 - { pattern: '*j*', expected: ['project_1', 'project_2'] }, 8 - { pattern: 'project*', expected: ['project_1', 'project_2'] }, 9 - { pattern: 'space*', expected: ['space_1'] }, 10 - ])('should match projects correctly: $pattern', async ({ pattern, expected }) => { 11 - const { stdout, stderr } = await runVitest({ 12 - root: 'fixtures/project', 13 - reporters: ['basic'], 14 - project: pattern, 15 - }) 16 - 17 - expect(stderr).toBeFalsy() 18 - expect(stdout).toBeTruthy() 19 - 20 - expected.forEach(name => expect(stdout).toContain(name)) 21 - })
+99
test/cli/test/public-api.test.ts
··· 1 + import { expect, it } from 'vitest' 2 + import type { File, TaskResultPack, UserConfig } from 'vitest' 3 + import { resolve } from 'pathe' 4 + import { runVitest } from '../../test-utils' 5 + 6 + it.each([ 7 + { name: 'threads are enabled', pool: 'threads' }, 8 + { name: 'threads are disabled', pool: 'forks' }, 9 + { 10 + name: 'running in the browser', 11 + browser: { 12 + enabled: true, 13 + provider: 'playwright', 14 + name: 'chromium', 15 + headless: true, 16 + }, 17 + }, 18 + ] as UserConfig[])('passes down metadata when $name', { timeout: 60_000, retry: 3 }, async (config) => { 19 + const taskUpdate: TaskResultPack[] = [] 20 + const finishedFiles: File[] = [] 21 + const collectedFiles: File[] = [] 22 + const { ctx, stdout, stderr } = await runVitest({ 23 + root: resolve(__dirname, '..', 'fixtures', 'public-api'), 24 + include: ['**/*.spec.ts'], 25 + reporters: [ 26 + 'verbose', 27 + { 28 + onTaskUpdate(packs) { 29 + taskUpdate.push(...packs.filter(i => i[1]?.state === 'pass')) 30 + }, 31 + onFinished(files) { 32 + finishedFiles.push(...files || []) 33 + }, 34 + onCollected(files) { 35 + collectedFiles.push(...files || []) 36 + }, 37 + }, 38 + ], 39 + includeTaskLocation: true, 40 + ...config, 41 + }) 42 + 43 + expect(stderr).toBe('') 44 + 45 + expect(stdout).toContain('custom.spec.ts > custom') 46 + 47 + const suiteMeta = { done: true } 48 + const testMeta = { custom: 'some-custom-hanlder' } 49 + 50 + expect(taskUpdate).toHaveLength(4) 51 + expect(finishedFiles).toHaveLength(1) 52 + 53 + const files = ctx?.state.getFiles() || [] 54 + expect(files).toHaveLength(1) 55 + 56 + expect(taskUpdate).toContainEqual( 57 + [ 58 + expect.any(String), 59 + expect.anything(), 60 + suiteMeta, 61 + ], 62 + ) 63 + 64 + expect(taskUpdate).toContainEqual( 65 + [ 66 + expect.any(String), 67 + expect.anything(), 68 + testMeta, 69 + ], 70 + ) 71 + 72 + expect(finishedFiles[0].meta).toEqual(suiteMeta) 73 + expect(finishedFiles[0].tasks[0].meta).toEqual(testMeta) 74 + 75 + expect(files[0].meta).toEqual(suiteMeta) 76 + expect(files[0].tasks[0].meta).toEqual(testMeta) 77 + 78 + expect(finishedFiles[0].tasks[0].location).toEqual({ 79 + line: 14, 80 + column: 1, 81 + }) 82 + expect(collectedFiles[0].tasks[0].location).toEqual({ 83 + line: 14, 84 + column: 1, 85 + }) 86 + expect(files[0].tasks[0].location).toEqual({ 87 + line: 14, 88 + column: 1, 89 + }) 90 + 91 + const eachTests = [1, 2] 92 + eachTests.forEach((name, index) => { 93 + expect(files[0].tasks[index + 1].name).toBe(`custom ${name}`) 94 + expect(files[0].tasks[index + 1].location).toEqual({ 95 + line: 18, 96 + column: 18, 97 + }) 98 + }) 99 + })
+14
test/cli/test/restricted-fs.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { runVitest } from '../../test-utils' 4 + 5 + test('importing files in restricted fs works correctly', async () => { 6 + const { stderr, exitCode } = await runVitest({ 7 + root: './fixtures/restricted-fs', 8 + }) 9 + 10 + // It would fail if setupFile was not added to allowed fs 11 + // Failed to load url fixtures/restricted-fs/vitest.setup.js 12 + expect(stderr).toBe('') 13 + expect(exitCode).toBe(0) 14 + })
+19
test/cli/test/run-custom-env.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { runVitest } from '../../test-utils' 4 + 5 + test('correctly runs tests if custom env is a file', async () => { 6 + const { stderr, exitCode } = await runVitest({ 7 + root: './fixtures/custom-file-env', 8 + config: false, 9 + environment: '../../custom.ts', 10 + environmentOptions: { 11 + custom: { 12 + option: 'custom-option', 13 + }, 14 + }, 15 + }) 16 + 17 + expect(stderr).toBe('') 18 + expect(exitCode).toBe(0) 19 + })
+19
test/cli/test/server-url.test.ts
··· 1 + import { expect, it } from 'vitest' 2 + 3 + import { runVitest } from '../../test-utils' 4 + 5 + it('api server-url http', async () => { 6 + delete process.env.TEST_HTTPS 7 + const { stdout } = await runVitest({ root: './fixtures/ws-server-url', api: true }) 8 + expect(stdout).toContain('API started at http://localhost:51204/') 9 + expect(stdout).toContain('Test Files 1 passed') 10 + }) 11 + 12 + it('api server-url https', async () => { 13 + process.env.TEST_HTTPS = '1' 14 + const { stdout } = await runVitest({ root: './fixtures/ws-server-url', api: true }) 15 + expect(stdout).toContain('API started at https://localhost:51204/') 16 + expect(stdout).toContain('Test Files 1 passed') 17 + }) 18 + 19 + it.todo('api server-url fallback if resolvedUrls is null')
+42
test/cli/test/setup-files.test.ts
··· 1 + import { promises as fs } from 'node:fs' 2 + import { describe, expect, it, test } from 'vitest' 3 + import { editFile, runVitest } from '../../test-utils' 4 + 5 + test('print stdout and stderr correctly when called in the setup file', async () => { 6 + const { stdout, stderr } = await runVitest({ 7 + root: 'fixtures/setup-files', 8 + include: ['empty.test.ts'], 9 + setupFiles: ['./console-setup.ts'], 10 + }) 11 + 12 + const filepath = 'console-setup.ts' 13 + expect(stdout).toContain(`stdout | ${filepath}`) 14 + expect(stderr).toContain(`stderr | ${filepath}`) 15 + }) 16 + 17 + describe('setup files with forceRerunTrigger', () => { 18 + const file = './fixtures/setup-files/empty-setup.ts' 19 + 20 + async function run() { 21 + return await runVitest({ 22 + root: 'fixtures/setup-files', 23 + include: ['empty.test.ts'], 24 + setupFiles: ['./empty-setup.ts'], 25 + changed: true, 26 + }) 27 + } 28 + 29 + // Note that this test will fail locally if you have uncommitted changes 30 + it.runIf(process.env.GITHUB_ACTIONS)('should run no tests if setup file is not changed', async () => { 31 + const { stdout } = await run() 32 + expect(stdout).toContain('No test files found, exiting with code 0') 33 + }) 34 + 35 + it('should run the whole test suite if setup file is changed', async () => { 36 + const codes = 'export const a = 1' 37 + editFile(file, () => codes) 38 + await fs.writeFile(file, codes, 'utf-8') 39 + const { stdout } = await run() 40 + expect(stdout).toContain('1 passed') 41 + }) 42 + })
+79
test/cli/test/stacktraces.test.ts
··· 1 + import { resolve } from 'pathe' 2 + import fg from 'fast-glob' 3 + import { describe, expect, it } from 'vitest' 4 + 5 + import { runVitest } from '../../test-utils' 6 + 7 + // To prevent the warnining coming up in snapshots 8 + process.setMaxListeners(20) 9 + 10 + describe('stacktraces should respect sourcemaps', async () => { 11 + const root = resolve(__dirname, '../fixtures/stacktraces') 12 + const files = await fg('*.test.*', { cwd: root }) 13 + 14 + for (const file of files) { 15 + it(file, async () => { 16 + const { stderr } = await runVitest({ root }, [file]) 17 + 18 + expect(stderr).toBeTruthy() 19 + const lines = String(stderr).split(/\n/g) 20 + const index = lines.findIndex(val => val.includes(`${file}:`)) 21 + const msg = lines.slice(index, index + 8).join('\n') 22 + expect(msg).toMatchSnapshot(file) 23 + }) 24 + } 25 + }) 26 + 27 + describe('stacktraces should pick error frame if present', async () => { 28 + const root = resolve(__dirname, '../fixtures/stacktraces') 29 + const files = ['frame.spec.imba'] 30 + 31 + for (const file of files) { 32 + it(file, async () => { 33 + const { stderr } = await runVitest({ root }, [file]) 34 + 35 + expect(stderr).toBeTruthy() 36 + const lines = String(stderr).split(/\n/g) 37 + const index = lines.findIndex(val => val.includes('FAIL')) 38 + const msg = lines.slice(index, index + 8).join('\n') 39 + expect(msg).toMatchSnapshot(file) 40 + }) 41 + } 42 + }) 43 + 44 + describe('stacktrace should print error frame source file correctly', async () => { 45 + const root = resolve(__dirname, '../fixtures/stacktraces') 46 + const testFile = resolve(root, './error-in-deps.test.js') 47 + 48 + it('error-in-deps', async () => { 49 + const { stderr } = await runVitest({ root }, [testFile]) 50 + 51 + // expect to print framestack of foo.js 52 + expect(stderr).toMatchSnapshot('error-in-deps') 53 + }) 54 + }) 55 + 56 + describe('stacktrace filtering', async () => { 57 + const root = resolve(__dirname, '../fixtures/stacktraces') 58 + const testFile = resolve(root, './error-with-stack.test.js') 59 + 60 + it('filters stacktraces', async () => { 61 + const { stderr } = await runVitest({ 62 + root, 63 + onStackTrace: (_error, { method }) => method !== 'b', 64 + }, [testFile]) 65 + 66 + expect(stderr).toMatchSnapshot('stacktrace-filtering') 67 + }) 68 + }) 69 + 70 + it('stacktrace in vmThreads', async () => { 71 + const root = resolve(__dirname, '../fixtures/stacktraces') 72 + const testFile = resolve(root, './error-with-stack.test.js') 73 + const { stderr } = await runVitest({ 74 + root, 75 + pool: 'vmThreads', 76 + }, [testFile]) 77 + 78 + expect(stderr).toMatchSnapshot() 79 + })
+14
test/cli/test/tty.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + import { runVitestCli } from '../../test-utils' 3 + 4 + test('run mode does not get stuck when TTY', async () => { 5 + const { vitest } = await runVitestCli('--root', 'fixtures/tty') 6 + 7 + await vitest.waitForStdout('✓ example.test.ts') 8 + await vitest.waitForStdout('✓ math.test.ts') 9 + await vitest.waitForStdout('2 passed') 10 + 11 + // Regression #3642 12 + expect(vitest.stderr).not.toContain('close timed out') 13 + expect(vitest.stderr).toBe('') 14 + })
+17
test/cli/test/vm-threads.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { createFile, resolvePath, runVitest } from '../../test-utils' 4 + 5 + test('importing files in restricted fs works correctly', async () => { 6 + createFile( 7 + resolvePath(import.meta.url, '../fixtures/vm-threads/src/external/package-null/package-null.json'), 8 + 'null', 9 + ) 10 + 11 + const { stderr, exitCode } = await runVitest({ 12 + root: './fixtures/vm-threads', 13 + }) 14 + 15 + expect(stderr).toBe('') 16 + expect(exitCode).toBe(0) 17 + })
+3
test/config/fixtures/vitest.config.js
··· 1 + export default { 2 + test: {} 3 + }
+57
test/config/test/bail.test.ts
··· 1 + import { type UserConfig, expect, test } from 'vitest' 2 + 3 + import { runVitest } from '../../test-utils' 4 + 5 + const configs: UserConfig[] = [] 6 + const pools: UserConfig[] = [{ pool: 'threads' }, { pool: 'forks' }, { pool: 'threads', poolOptions: { threads: { singleThread: true } } }] 7 + 8 + if (process.platform !== 'win32') 9 + pools.push({ browser: { enabled: true, name: 'chromium', provider: 'playwright' } }) 10 + 11 + for (const isolate of [true, false]) { 12 + for (const pool of pools) { 13 + configs.push({ 14 + ...pool, 15 + poolOptions: { 16 + threads: { 17 + ...pool.poolOptions?.threads, 18 + isolate, 19 + }, 20 + forks: { isolate }, 21 + }, 22 + }) 23 + } 24 + } 25 + 26 + for (const config of configs) { 27 + test( 28 + `should bail with "${JSON.stringify(config)}"`, 29 + { 30 + retry: config.browser?.enabled ? 3 : 0, 31 + }, 32 + async () => { 33 + const isParallel 34 + = (config.pool === 'threads' && config.poolOptions?.threads?.singleThread !== true) 35 + || (config.pool === 'forks' && config.poolOptions?.forks?.singleFork !== true) 36 + 37 + // THREADS here means that multiple tests are run parallel 38 + process.env.THREADS = isParallel ? 'true' : 'false' 39 + 40 + const { exitCode, stdout } = await runVitest({ 41 + root: './fixtures/bail', 42 + bail: 1, 43 + ...config, 44 + }) 45 + 46 + expect(exitCode).toBe(1) 47 + expect(stdout).toMatch('✓ test/first.test.ts > 1 - first.test.ts - this should pass') 48 + expect(stdout).toMatch('× test/first.test.ts > 2 - first.test.ts - this should fail') 49 + 50 + // Cancelled tests should not be run 51 + expect(stdout).not.toMatch('test/first.test.ts > 3 - first.test.ts - this should be skipped') 52 + expect(stdout).not.toMatch('test/second.test.ts > 1 - second.test.ts - this should be skipped') 53 + expect(stdout).not.toMatch('test/second.test.ts > 2 - second.test.ts - this should be skipped') 54 + expect(stdout).not.toMatch('test/second.test.ts > 3 - second.test.ts - this should be skipped') 55 + }, 56 + ) 57 + }
+12
test/config/test/base-path.test.ts
··· 1 + import { expect, it } from 'vitest' 2 + import { runVitest } from '../../test-utils' 3 + 4 + it('correctly runs tests with a "base" specified in the config', async () => { 5 + const { stderr, exitCode } = await runVitest({ 6 + root: './fixtures/base-path', 7 + }, [], 'test', { 8 + base: '/some/base/url', 9 + }) 10 + expect(stderr).toBe('') 11 + expect(exitCode).toBe(0) 12 + })
+21
test/config/test/css-configs.test.ts
··· 1 + import { expect, it } from 'vitest' 2 + import { runVitest } from '../../test-utils' 3 + 4 + it.each([ 5 + ['test/default-css', {}], 6 + ['test/process-css', { include: [/App\.css/] }], 7 + [['test/process-module', 'test/process-inline'], { include: [/App\.module\.css/] }], 8 + ['test/scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'scoped' as const } }], 9 + ['test/non-scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'non-scoped' as const } }], 10 + ])('testing %s', async (name, config) => { 11 + const names = Array.isArray(name) ? name : [name] 12 + const { stderr } = await runVitest({ 13 + config: false, 14 + root: './fixtures/css', 15 + css: config, 16 + update: true, 17 + environment: 'jsdom', 18 + }, names) 19 + 20 + expect(stderr).toBe('') 21 + })
+14
test/config/test/exclude.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { runVitest } from '../../test-utils' 4 + 5 + test('should still test math.test.ts', async () => { 6 + const { stderr, stdout } = await runVitest({ 7 + config: 'fixtures/exclude/vitest.exclude.config.ts', 8 + exclude: ['fixtures/exclude/string.test.ts'], 9 + }) 10 + 11 + expect(stdout).toContain(`✓ fixtures/exclude/math.test.ts`) 12 + expect(stdout).not.toContain(`string.test.ts`) 13 + expect(stderr).toBe('') 14 + })
+76
test/config/test/exec-args.test.ts
··· 1 + import { afterAll, beforeAll, expect, test } from 'vitest' 2 + import { execa } from 'execa' 3 + import { runVitest } from '../../test-utils' 4 + 5 + // VITEST_SEGFAULT_RETRY messes with the node flags, as can be seen in packages/vitest/src/node/cli-wrapper.ts 6 + // so here we remove it to make sure the tests are not affected by it 7 + const ORIGIN_VITEST_SEGFAULT_RETRY = process.env.VITEST_SEGFAULT_RETRY 8 + beforeAll(() => { 9 + delete process.env.VITEST_SEGFAULT_RETRY 10 + }) 11 + afterAll(() => { 12 + process.env.VITEST_SEGFAULT_RETRY = ORIGIN_VITEST_SEGFAULT_RETRY 13 + }) 14 + 15 + test.each([ 16 + { pool: 'forks', execArgv: ['--hash-seed=1', '--random-seed=1', '--no-opt'] }, 17 + { pool: 'threads', execArgv: ['--inspect-brk'] }, 18 + { pool: 'vmThreads', execArgv: ['--inspect-brk'] }, 19 + ] as const)('should pass execArgv to { pool: $pool } ', async ({ pool, execArgv }) => { 20 + const root = './fixtures/exec-args-fixtures' 21 + const fileToTest = `${pool}.test.ts` 22 + 23 + const vitest = await runVitest({ 24 + root, 25 + include: [fileToTest], 26 + pool, 27 + poolOptions: { 28 + [pool]: { 29 + execArgv, 30 + }, 31 + }, 32 + }) 33 + 34 + expect(vitest.stdout).toContain(`✓ ${fileToTest}`) 35 + expect(vitest.stderr).toBe('') 36 + }) 37 + 38 + test('should not pass execArgv to workers when not specified in the config', async () => { 39 + const { stdout, stderr } = await execa('node', [ 40 + '--title', 41 + 'this-works-only-on-main-thread', 42 + '../../../../node_modules/vitest/vitest.mjs', 43 + '--run', 44 + ], { 45 + cwd: `${process.cwd()}/fixtures/no-exec-args-fixtures`, 46 + reject: false, 47 + env: { 48 + VITE_NODE_DEPS_MODULE_DIRECTORIES: '/node_modules/,/packages/', 49 + NO_COLOR: '1', 50 + }, 51 + }) 52 + 53 + expect(stderr).not.toContain('Error: Initiated Worker with invalid execArgv flags: --title') 54 + expect(stderr).not.toContain('ERR_WORKER_INVALID_EXEC_ARGV') 55 + expect(stdout).toContain('✓ no-exec-argv.test.ts') 56 + }) 57 + 58 + test('should let allowed args pass to workers', async () => { 59 + const { stdout, stderr } = await execa('node', [ 60 + '--heap-prof', 61 + '--diagnostic-dir=/tmp/vitest-diagnostics', 62 + '--heap-prof-name=heap.prof', 63 + '../../../../node_modules/vitest/vitest.mjs', 64 + '--run', 65 + ], { 66 + cwd: `${process.cwd()}/fixtures/allowed-exec-args-fixtures`, 67 + reject: false, 68 + env: { 69 + VITE_NODE_DEPS_MODULE_DIRECTORIES: '/node_modules/,/packages/', 70 + NO_COLOR: '1', 71 + }, 72 + }) 73 + 74 + expect(stderr).toBe('') 75 + expect(stdout).toContain('✓ allowed-exec-argv.test.ts') 76 + })
+5 -4
test/config/test/failures.test.ts
··· 6 6 import * as testUtils from '../../test-utils' 7 7 8 8 function runVitest(config: NonNullable<UserConfig['test']> & { shard?: any }) { 9 - return testUtils.runVitest(config, ['fixtures/test/']) 9 + return testUtils.runVitest({ root: './fixtures/test', ...config }, []) 10 10 } 11 11 12 12 function runVitestCli(...cliArgs: string[]) { ··· 70 70 71 71 test('coverage reportsDirectory cannot be current working directory', async () => { 72 72 const { stderr } = await runVitest({ 73 + root: undefined, 73 74 coverage: { 74 75 enabled: true, 75 76 reportsDirectory: './', ··· 88 89 89 90 test('coverage reportsDirectory cannot be root', async () => { 90 91 const { stderr } = await runVitest({ 91 - root: './fixtures', 92 + root: './fixtures/test', 92 93 coverage: { 93 94 enabled: true, 94 95 reportsDirectory: './', ··· 101 102 }, 102 103 }) 103 104 104 - const directory = normalize(resolve('./fixtures')) 105 + const directory = normalize(resolve('./fixtures/test')) 105 106 expect(stderr).toMatch(`Error: You cannot set "coverage.reportsDirectory" as ${directory}. Vitest needs to be able to remove this directory before test run`) 106 107 }) 107 108 ··· 145 146 const { stderr } = await runVitest({ 146 147 pool: 'forks', 147 148 fakeTimers: { toFake: ['nextTick'] }, 148 - include: ['./fixtures/test/fake-timers.test.ts'], 149 + include: ['./fake-timers.test.ts'], 149 150 }) 150 151 151 152 expect(stderr).toMatch('Error: vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.')
+27
test/config/test/mixed-environments.test.ts
··· 1 + import { type UserConfig, expect, test } from 'vitest' 2 + 3 + import { runVitest } from '../../test-utils' 4 + 5 + const configs: UserConfig[] = [ 6 + { pool: 'threads', poolOptions: { threads: { isolate: false, singleThread: true } } }, 7 + { pool: 'threads', poolOptions: { threads: { isolate: false, singleThread: false } } }, 8 + { pool: 'threads', poolOptions: { threads: { isolate: false, minThreads: 1, maxThreads: 1 } } }, 9 + { pool: 'forks', poolOptions: { forks: { isolate: true } } }, 10 + { pool: 'forks', poolOptions: { forks: { isolate: false } } }, 11 + ] 12 + 13 + test.each(configs)('should isolate environments when %s', async (config) => { 14 + const { stderr, stdout } = await runVitest({ 15 + root: './fixtures/mixed-environments', 16 + ...config, 17 + }) 18 + 19 + expect(stderr).toBe('') 20 + 21 + expect(stdout).toContain('✓ test/node.test.ts') 22 + expect(stdout).toContain('✓ test/jsdom.test.ts') 23 + expect(stdout).toContain('✓ test/happy-dom.test.ts') 24 + expect(stdout).toContain('✓ test/workspace-project.test.ts') 25 + expect(stdout).toContain('Test Files 8 passed (8)') 26 + expect(stdout).toContain('Tests 8 passed (8)') 27 + })
+317
test/config/test/override.test.ts
··· 1 + import { Writable } from 'node:stream' 2 + import type { UserConfig } from 'vitest' 3 + import type { UserConfig as ViteUserConfig } from 'vite' 4 + import { describe, expect, it } from 'vitest' 5 + import { createVitest, parseCLI } from 'vitest/node' 6 + import { extraInlineDeps } from 'vitest/config' 7 + 8 + type VitestOptions = Parameters<typeof createVitest>[3] 9 + 10 + async function vitest(cliOptions: UserConfig, configValue: UserConfig = {}, viteConfig: ViteUserConfig = {}, vitestOptions: VitestOptions = {}) { 11 + const vitest = await createVitest('test', { ...cliOptions, watch: false }, { ...viteConfig, test: configValue as any }, vitestOptions) 12 + return vitest 13 + } 14 + 15 + async function config(cliOptions: UserConfig, configValue: UserConfig = {}, viteConfig: ViteUserConfig = {}, vitestOptions: VitestOptions = {}) { 16 + const v = await vitest(cliOptions, configValue, viteConfig, vitestOptions) 17 + return v.config 18 + } 19 + 20 + describe('correctly defines isolated flags', async () => { 21 + it('does not merge user-defined poolOptions with itself', async () => { 22 + const c = await config({}, { 23 + poolOptions: { 24 + array: [1, 2, 3], 25 + }, 26 + }) 27 + // Ensure poolOptions.array has not been merged with itself 28 + // Previously, this would have been [1,2,3,1,2,3] 29 + expect(c.poolOptions?.array).toMatchInlineSnapshot(` 30 + [ 31 + 1, 32 + 2, 33 + 3, 34 + ] 35 + `) 36 + }) 37 + it('prefers CLI poolOptions flags over config', async () => { 38 + const c = await config({ 39 + isolate: true, 40 + poolOptions: { 41 + threads: { 42 + isolate: false, 43 + }, 44 + forks: { 45 + isolate: false, 46 + }, 47 + }, 48 + }) 49 + expect(c.poolOptions?.threads?.isolate).toBe(false) 50 + expect(c.poolOptions?.forks?.isolate).toBe(false) 51 + expect(c.isolate).toBe(true) 52 + }) 53 + 54 + it('override CLI poolOptions flags over isolate', async () => { 55 + const c = await config({ 56 + isolate: false, 57 + poolOptions: { 58 + threads: { 59 + isolate: true, 60 + }, 61 + forks: { 62 + isolate: true, 63 + }, 64 + }, 65 + }, { 66 + poolOptions: { 67 + threads: { 68 + isolate: false, 69 + }, 70 + forks: { 71 + isolate: false, 72 + }, 73 + }, 74 + }) 75 + expect(c.poolOptions?.threads?.isolate).toBe(true) 76 + expect(c.poolOptions?.forks?.isolate).toBe(true) 77 + expect(c.isolate).toBe(false) 78 + }) 79 + 80 + it('override CLI isolate flag if poolOptions is not set via CLI', async () => { 81 + const c = await config({ 82 + isolate: true, 83 + }, { 84 + poolOptions: { 85 + threads: { 86 + isolate: false, 87 + }, 88 + forks: { 89 + isolate: false, 90 + }, 91 + }, 92 + }) 93 + expect(c.poolOptions?.threads?.isolate).toBe(true) 94 + expect(c.poolOptions?.forks?.isolate).toBe(true) 95 + expect(c.isolate).toBe(true) 96 + }) 97 + 98 + it('keeps user configured poolOptions if no CLI flag is provided', async () => { 99 + const c = await config({}, { 100 + poolOptions: { 101 + threads: { 102 + isolate: false, 103 + }, 104 + forks: { 105 + isolate: false, 106 + }, 107 + }, 108 + }) 109 + expect(c.poolOptions?.threads?.isolate).toBe(false) 110 + expect(c.poolOptions?.forks?.isolate).toBe(false) 111 + expect(c.isolate).toBe(true) 112 + }) 113 + 114 + it('isolate config value overrides poolOptions defaults', async () => { 115 + const c = await config({}, { 116 + isolate: false, 117 + }) 118 + expect(c.poolOptions?.threads?.isolate).toBe(false) 119 + expect(c.poolOptions?.forks?.isolate).toBe(false) 120 + expect(c.isolate).toBe(false) 121 + }) 122 + 123 + it('if no isolation is defined in the config, fallback ot undefined', async () => { 124 + const c = await config({}, {}) 125 + expect(c.poolOptions?.threads?.isolate).toBe(undefined) 126 + expect(c.poolOptions?.forks?.isolate).toBe(undefined) 127 + // set in configDefaults, so it's always defined 128 + expect(c.isolate).toBe(true) 129 + }) 130 + }) 131 + 132 + describe('correctly defines inline and noExternal flags', async () => { 133 + it('both are true if inline is true', async () => { 134 + const v = await vitest({}, { 135 + server: { 136 + deps: { 137 + inline: true, 138 + }, 139 + }, 140 + }) 141 + expect(v.vitenode.options.deps?.inline).toBe(true) 142 + expect(v.vitenode.server.config.ssr.noExternal).toBe(true) 143 + }) 144 + 145 + it('both are true if noExternal is true', async () => { 146 + const v = await vitest({}, {}, { 147 + ssr: { 148 + noExternal: true, 149 + }, 150 + }) 151 + expect(v.vitenode.options.deps?.inline).toBe(true) 152 + expect(v.vitenode.server.config.ssr.noExternal).toBe(true) 153 + }) 154 + 155 + it('inline are added to noExternal', async () => { 156 + const regexp1 = /dep1/ 157 + const regexp2 = /dep2/ 158 + 159 + const v = await vitest({}, { 160 + server: { 161 + deps: { 162 + inline: ['dep1', 'dep2', regexp1, regexp2], 163 + }, 164 + }, 165 + }) 166 + 167 + expect(v.vitenode.options.deps?.inline).toEqual([ 168 + 'dep1', 169 + 'dep2', 170 + regexp1, 171 + regexp2, 172 + ...extraInlineDeps, 173 + ]) 174 + expect(v.server.config.ssr.noExternal).toEqual([ 175 + 'dep1', 176 + 'dep2', 177 + regexp1, 178 + regexp2, 179 + ...extraInlineDeps, 180 + ]) 181 + }) 182 + 183 + it('noExternal are added to inline', async () => { 184 + const regexp1 = /dep1/ 185 + const regexp2 = /dep2/ 186 + 187 + const v = await vitest({}, {}, { 188 + ssr: { 189 + noExternal: ['dep1', 'dep2', regexp1, regexp2], 190 + }, 191 + }) 192 + 193 + expect(v.vitenode.options.deps?.inline).toEqual([ 194 + ...extraInlineDeps, 195 + 'dep1', 196 + 'dep2', 197 + regexp1, 198 + regexp2, 199 + ]) 200 + expect(v.server.config.ssr.noExternal).toEqual([ 201 + 'dep1', 202 + 'dep2', 203 + regexp1, 204 + regexp2, 205 + ]) 206 + }) 207 + 208 + it('noExternal and inline don\'t have duplicates', async () => { 209 + const regexp1 = /dep1/ 210 + const regexp2 = /dep2/ 211 + 212 + const v = await vitest({}, { 213 + server: { 214 + deps: { 215 + inline: ['dep2', regexp1, 'dep3'], 216 + }, 217 + }, 218 + }, { 219 + ssr: { 220 + noExternal: ['dep1', 'dep2', regexp1, regexp2], 221 + }, 222 + }) 223 + 224 + expect(v.vitenode.options.deps?.inline).toEqual([ 225 + 'dep2', 226 + regexp1, 227 + 'dep3', 228 + ...extraInlineDeps, 229 + 'dep1', 230 + regexp2, 231 + ]) 232 + expect(v.server.config.ssr.noExternal).toEqual([ 233 + 'dep1', 234 + 'dep2', 235 + regexp1, 236 + regexp2, 237 + 'dep3', 238 + ]) 239 + }) 240 + }) 241 + 242 + describe('correctly defines api flag', () => { 243 + it('CLI overrides disabling api', async () => { 244 + const c = await vitest({ api: false }, { 245 + api: { 246 + port: 1234, 247 + }, 248 + watch: true, 249 + }) 250 + expect(c.server.config.server.middlewareMode).toBe(true) 251 + expect(c.config.api).toEqual({ 252 + middlewareMode: true, 253 + }) 254 + }) 255 + 256 + it('CLI overrides inlined value', async () => { 257 + const c = await vitest({ api: { port: 4321 } }, { 258 + api: { 259 + port: 1234, 260 + }, 261 + watch: true, 262 + }) 263 + expect(c.server.config.server.port).toBe(4321) 264 + expect(c.config.api).toEqual({ 265 + port: 4321, 266 + }) 267 + }) 268 + }) 269 + 270 + describe.each([ 271 + '--inspect', 272 + '--inspect-brk', 273 + ])('correctly parses %s flags', (inspectFlagName) => { 274 + it.each([ 275 + ['', { enabled: true }], 276 + ['true', { enabled: true }], 277 + ['yes', { enabled: true }], 278 + ['false', { enabled: false }], 279 + ['no', { enabled: false }], 280 + 281 + ['1002', { enabled: true, port: 1002 }], 282 + ['www.remote.com:1002', { enabled: true, port: 1002, host: 'www.remote.com' }], 283 + ['www.remote.com', { enabled: true, host: 'www.remote.com' }], 284 + ])(`parses "vitest ${inspectFlagName} %s" value`, async (cliValue, inspect) => { 285 + const rawConfig = parseCLI( 286 + `vitest --no-file-parallelism ${inspectFlagName} ${cliValue}`, 287 + ) 288 + const c = await config(rawConfig.options) 289 + expect(c.inspector).toEqual({ 290 + ...inspect, 291 + waitForDebugger: inspectFlagName === '--inspect-brk' && inspect.enabled, 292 + }) 293 + }) 294 + it('cannot use a URL', async () => { 295 + const url = 'https://www.remote.com:1002' 296 + const rawConfig = parseCLI([ 297 + 'vitest', 298 + '--no-file-parallelism', 299 + inspectFlagName, 300 + url, 301 + ]) 302 + const errors: string[] = [] 303 + const stderr = new Writable({ 304 + write(chunk, _encoding, callback) { 305 + errors.push(chunk.toString()) 306 + callback() 307 + }, 308 + }) 309 + await expect(async () => { 310 + await config(rawConfig.options, {}, {}, { stderr }) 311 + }).rejects.toThrowError() 312 + 313 + expect(errors[0]).toEqual( 314 + expect.stringContaining(`Inspector host cannot be a URL. Use "host:port" instead of "${url}"`), 315 + ) 316 + }) 317 + })
+10
test/config/test/pass-empty-files.test.ts
··· 1 + import { expect, it } from 'vitest' 2 + import { runVitest } from '../../test-utils' 3 + 4 + it('vitest doesnt fail when running empty files', async () => { 5 + const { exitCode } = await runVitest({ 6 + root: './fixtures/pass-empty-files', 7 + passWithNoTests: true, 8 + }) 9 + expect(exitCode).toBe(0) 10 + })
+21
test/config/test/project.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + import { runVitest } from '../../test-utils' 3 + 4 + test.each([ 5 + { pattern: 'project_1', expected: ['project_1'] }, 6 + { pattern: '*', expected: ['project_1', 'project_2', 'space_1'] }, 7 + { pattern: '*j*', expected: ['project_1', 'project_2'] }, 8 + { pattern: 'project*', expected: ['project_1', 'project_2'] }, 9 + { pattern: 'space*', expected: ['space_1'] }, 10 + ])('should match projects correctly: $pattern', async ({ pattern, expected }) => { 11 + const { stdout, stderr } = await runVitest({ 12 + root: 'fixtures/project', 13 + reporters: ['basic'], 14 + project: pattern, 15 + }) 16 + 17 + expect(stderr).toBeFalsy() 18 + expect(stdout).toBeTruthy() 19 + 20 + expected.forEach(name => expect(stdout).toContain(name)) 21 + })
-317
test/config/test/resolution.test.ts
··· 1 - import { Writable } from 'node:stream' 2 - import type { UserConfig } from 'vitest' 3 - import type { UserConfig as ViteUserConfig } from 'vite' 4 - import { describe, expect, it } from 'vitest' 5 - import { createVitest, parseCLI } from 'vitest/node' 6 - import { extraInlineDeps } from 'vitest/config' 7 - 8 - type VitestOptions = Parameters<typeof createVitest>[3] 9 - 10 - async function vitest(cliOptions: UserConfig, configValue: UserConfig = {}, viteConfig: ViteUserConfig = {}, vitestOptions: VitestOptions = {}) { 11 - const vitest = await createVitest('test', { ...cliOptions, watch: false }, { ...viteConfig, test: configValue as any }, vitestOptions) 12 - return vitest 13 - } 14 - 15 - async function config(cliOptions: UserConfig, configValue: UserConfig = {}, viteConfig: ViteUserConfig = {}, vitestOptions: VitestOptions = {}) { 16 - const v = await vitest(cliOptions, configValue, viteConfig, vitestOptions) 17 - return v.config 18 - } 19 - 20 - describe('correctly defines isolated flags', async () => { 21 - it('does not merge user-defined poolOptions with itself', async () => { 22 - const c = await config({}, { 23 - poolOptions: { 24 - array: [1, 2, 3], 25 - }, 26 - }) 27 - // Ensure poolOptions.array has not been merged with itself 28 - // Previously, this would have been [1,2,3,1,2,3] 29 - expect(c.poolOptions?.array).toMatchInlineSnapshot(` 30 - [ 31 - 1, 32 - 2, 33 - 3, 34 - ] 35 - `) 36 - }) 37 - it('prefers CLI poolOptions flags over config', async () => { 38 - const c = await config({ 39 - isolate: true, 40 - poolOptions: { 41 - threads: { 42 - isolate: false, 43 - }, 44 - forks: { 45 - isolate: false, 46 - }, 47 - }, 48 - }) 49 - expect(c.poolOptions?.threads?.isolate).toBe(false) 50 - expect(c.poolOptions?.forks?.isolate).toBe(false) 51 - expect(c.isolate).toBe(true) 52 - }) 53 - 54 - it('override CLI poolOptions flags over isolate', async () => { 55 - const c = await config({ 56 - isolate: false, 57 - poolOptions: { 58 - threads: { 59 - isolate: true, 60 - }, 61 - forks: { 62 - isolate: true, 63 - }, 64 - }, 65 - }, { 66 - poolOptions: { 67 - threads: { 68 - isolate: false, 69 - }, 70 - forks: { 71 - isolate: false, 72 - }, 73 - }, 74 - }) 75 - expect(c.poolOptions?.threads?.isolate).toBe(true) 76 - expect(c.poolOptions?.forks?.isolate).toBe(true) 77 - expect(c.isolate).toBe(false) 78 - }) 79 - 80 - it('override CLI isolate flag if poolOptions is not set via CLI', async () => { 81 - const c = await config({ 82 - isolate: true, 83 - }, { 84 - poolOptions: { 85 - threads: { 86 - isolate: false, 87 - }, 88 - forks: { 89 - isolate: false, 90 - }, 91 - }, 92 - }) 93 - expect(c.poolOptions?.threads?.isolate).toBe(true) 94 - expect(c.poolOptions?.forks?.isolate).toBe(true) 95 - expect(c.isolate).toBe(true) 96 - }) 97 - 98 - it('keeps user configured poolOptions if no CLI flag is provided', async () => { 99 - const c = await config({}, { 100 - poolOptions: { 101 - threads: { 102 - isolate: false, 103 - }, 104 - forks: { 105 - isolate: false, 106 - }, 107 - }, 108 - }) 109 - expect(c.poolOptions?.threads?.isolate).toBe(false) 110 - expect(c.poolOptions?.forks?.isolate).toBe(false) 111 - expect(c.isolate).toBe(true) 112 - }) 113 - 114 - it('isolate config value overrides poolOptions defaults', async () => { 115 - const c = await config({}, { 116 - isolate: false, 117 - }) 118 - expect(c.poolOptions?.threads?.isolate).toBe(false) 119 - expect(c.poolOptions?.forks?.isolate).toBe(false) 120 - expect(c.isolate).toBe(false) 121 - }) 122 - 123 - it('if no isolation is defined in the config, fallback ot undefined', async () => { 124 - const c = await config({}, {}) 125 - expect(c.poolOptions?.threads?.isolate).toBe(undefined) 126 - expect(c.poolOptions?.forks?.isolate).toBe(undefined) 127 - // set in configDefaults, so it's always defined 128 - expect(c.isolate).toBe(true) 129 - }) 130 - }) 131 - 132 - describe('correctly defines inline and noExternal flags', async () => { 133 - it('both are true if inline is true', async () => { 134 - const v = await vitest({}, { 135 - server: { 136 - deps: { 137 - inline: true, 138 - }, 139 - }, 140 - }) 141 - expect(v.vitenode.options.deps?.inline).toBe(true) 142 - expect(v.vitenode.server.config.ssr.noExternal).toBe(true) 143 - }) 144 - 145 - it('both are true if noExternal is true', async () => { 146 - const v = await vitest({}, {}, { 147 - ssr: { 148 - noExternal: true, 149 - }, 150 - }) 151 - expect(v.vitenode.options.deps?.inline).toBe(true) 152 - expect(v.vitenode.server.config.ssr.noExternal).toBe(true) 153 - }) 154 - 155 - it('inline are added to noExternal', async () => { 156 - const regexp1 = /dep1/ 157 - const regexp2 = /dep2/ 158 - 159 - const v = await vitest({}, { 160 - server: { 161 - deps: { 162 - inline: ['dep1', 'dep2', regexp1, regexp2], 163 - }, 164 - }, 165 - }) 166 - 167 - expect(v.vitenode.options.deps?.inline).toEqual([ 168 - 'dep1', 169 - 'dep2', 170 - regexp1, 171 - regexp2, 172 - ...extraInlineDeps, 173 - ]) 174 - expect(v.server.config.ssr.noExternal).toEqual([ 175 - 'dep1', 176 - 'dep2', 177 - regexp1, 178 - regexp2, 179 - ...extraInlineDeps, 180 - ]) 181 - }) 182 - 183 - it('noExternal are added to inline', async () => { 184 - const regexp1 = /dep1/ 185 - const regexp2 = /dep2/ 186 - 187 - const v = await vitest({}, {}, { 188 - ssr: { 189 - noExternal: ['dep1', 'dep2', regexp1, regexp2], 190 - }, 191 - }) 192 - 193 - expect(v.vitenode.options.deps?.inline).toEqual([ 194 - ...extraInlineDeps, 195 - 'dep1', 196 - 'dep2', 197 - regexp1, 198 - regexp2, 199 - ]) 200 - expect(v.server.config.ssr.noExternal).toEqual([ 201 - 'dep1', 202 - 'dep2', 203 - regexp1, 204 - regexp2, 205 - ]) 206 - }) 207 - 208 - it('noExternal and inline don\'t have duplicates', async () => { 209 - const regexp1 = /dep1/ 210 - const regexp2 = /dep2/ 211 - 212 - const v = await vitest({}, { 213 - server: { 214 - deps: { 215 - inline: ['dep2', regexp1, 'dep3'], 216 - }, 217 - }, 218 - }, { 219 - ssr: { 220 - noExternal: ['dep1', 'dep2', regexp1, regexp2], 221 - }, 222 - }) 223 - 224 - expect(v.vitenode.options.deps?.inline).toEqual([ 225 - 'dep2', 226 - regexp1, 227 - 'dep3', 228 - ...extraInlineDeps, 229 - 'dep1', 230 - regexp2, 231 - ]) 232 - expect(v.server.config.ssr.noExternal).toEqual([ 233 - 'dep1', 234 - 'dep2', 235 - regexp1, 236 - regexp2, 237 - 'dep3', 238 - ]) 239 - }) 240 - }) 241 - 242 - describe('correctly defines api flag', () => { 243 - it('CLI overrides disabling api', async () => { 244 - const c = await vitest({ api: false }, { 245 - api: { 246 - port: 1234, 247 - }, 248 - watch: true, 249 - }) 250 - expect(c.server.config.server.middlewareMode).toBe(true) 251 - expect(c.config.api).toEqual({ 252 - middlewareMode: true, 253 - }) 254 - }) 255 - 256 - it('CLI overrides inlined value', async () => { 257 - const c = await vitest({ api: { port: 4321 } }, { 258 - api: { 259 - port: 1234, 260 - }, 261 - watch: true, 262 - }) 263 - expect(c.server.config.server.port).toBe(4321) 264 - expect(c.config.api).toEqual({ 265 - port: 4321, 266 - }) 267 - }) 268 - }) 269 - 270 - describe.each([ 271 - '--inspect', 272 - '--inspect-brk', 273 - ])('correctly parses %s flags', (inspectFlagName) => { 274 - it.each([ 275 - ['', { enabled: true }], 276 - ['true', { enabled: true }], 277 - ['yes', { enabled: true }], 278 - ['false', { enabled: false }], 279 - ['no', { enabled: false }], 280 - 281 - ['1002', { enabled: true, port: 1002 }], 282 - ['www.remote.com:1002', { enabled: true, port: 1002, host: 'www.remote.com' }], 283 - ['www.remote.com', { enabled: true, host: 'www.remote.com' }], 284 - ])(`parses "vitest ${inspectFlagName} %s" value`, async (cliValue, inspect) => { 285 - const rawConfig = parseCLI( 286 - `vitest --no-file-parallelism ${inspectFlagName} ${cliValue}`, 287 - ) 288 - const c = await config(rawConfig.options) 289 - expect(c.inspector).toEqual({ 290 - ...inspect, 291 - waitForDebugger: inspectFlagName === '--inspect-brk' && inspect.enabled, 292 - }) 293 - }) 294 - it('cannot use a URL', async () => { 295 - const url = 'https://www.remote.com:1002' 296 - const rawConfig = parseCLI([ 297 - 'vitest', 298 - '--no-file-parallelism', 299 - inspectFlagName, 300 - url, 301 - ]) 302 - const errors: string[] = [] 303 - const stderr = new Writable({ 304 - write(chunk, _encoding, callback) { 305 - errors.push(chunk.toString()) 306 - callback() 307 - }, 308 - }) 309 - await expect(async () => { 310 - await config(rawConfig.options, {}, {}, { stderr }) 311 - }).rejects.toThrowError() 312 - 313 - expect(errors[0]).toEqual( 314 - expect.stringContaining(`Inspector host cannot be a URL. Use "host:port" instead of "${url}"`), 315 - ) 316 - }) 317 - })
+50
test/config/test/shard.test.ts
··· 1 + import { type UserConfig, expect, test } from 'vitest' 2 + import { basename } from 'pathe' 3 + 4 + import * as testUtils from '../../test-utils' 5 + 6 + function runVitest(config: UserConfig) { 7 + return testUtils.runVitest({ ...config, root: './fixtures/shard' }) 8 + } 9 + 10 + function parsePaths(stdout: string) { 11 + return Array.from(new Set(stdout 12 + .split('\n') 13 + .filter(line => line && line.includes('.test.js')) 14 + .map(file => basename(file.trim().split(' ')[1])) 15 + .sort())) 16 + } 17 + 18 + test('--shard=1/1', async () => { 19 + const { stdout } = await runVitest({ shard: '1/1' }) 20 + 21 + const paths = parsePaths(stdout) 22 + 23 + expect(paths).toEqual(['1.test.js', '2.test.js', '3.test.js']) 24 + }) 25 + 26 + test('--shard=1/2', async () => { 27 + const { stdout } = await runVitest({ shard: '1/2' }) 28 + 29 + const paths = parsePaths(stdout) 30 + 31 + expect(paths).toEqual(['1.test.js', '2.test.js']) 32 + }) 33 + 34 + test('--shard=2/2', async () => { 35 + const { stdout } = await runVitest({ shard: '2/2' }) 36 + 37 + const paths = parsePaths(stdout) 38 + 39 + expect(paths).toEqual(['3.test.js']) 40 + }) 41 + 42 + test('--shard=4/4', async () => { 43 + const { stdout } = await runVitest({ shard: '4/4' }) 44 + 45 + const paths = parsePaths(stdout) 46 + 47 + // project only has 3 files 48 + // shards > 3 are empty 49 + expect(paths).toEqual([]) 50 + })
+86
test/config/test/testname-pattern.test.ts
··· 1 + import { join, resolve } from 'pathe' 2 + import { expect, test } from 'vitest' 3 + 4 + import { runVitest } from '../../test-utils' 5 + 6 + test.each([ 7 + { filter: 'example' }, 8 + { filter: '/example' }, 9 + { filter: resolve('./fixtures/filters/test/example') }, 10 + ])('match by partial pattern $filter', async ({ filter }) => { 11 + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filter]) 12 + 13 + expect(stdout).toMatch('✓ test/example.test.ts > this will pass') 14 + expect(stdout).toMatch('Test Files 1 passed (1)') 15 + expect(stdout).not.toMatch('test/config.test.ts') 16 + }) 17 + 18 + test('match by full test file name', async () => { 19 + const filename = resolve('./fixtures/filters/test/example.test.ts') 20 + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filename]) 21 + 22 + expect(stdout).toMatch('✓ test/example.test.ts > this will pass') 23 + expect(stdout).toMatch('Test Files 1 passed (1)') 24 + expect(stdout).not.toMatch('test/filters.test.ts') 25 + }) 26 + 27 + test('match by pattern that also matches current working directory', async () => { 28 + const filter = 'config' 29 + expect(process.cwd()).toMatch(filter) 30 + 31 + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filter]) 32 + 33 + expect(stdout).toMatch('✓ test/config.test.ts > this will pass') 34 + expect(stdout).toMatch('Test Files 1 passed (1)') 35 + expect(stdout).not.toMatch('test/example.test.ts') 36 + }) 37 + 38 + test.each([ 39 + ['the parent of CWD', resolve(process.cwd(), '..')], 40 + ['the parent of CWD with slash', join(resolve(process.cwd(), '..'), '/')], 41 + ['the parent of a parent of CWD', resolve(process.cwd(), '..', '..')], 42 + ])('match by pattern that also matches %s: %s', async (_, filter) => { 43 + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filter]) 44 + 45 + expect(stdout).toMatch('✓ test/config.test.ts > this will pass') 46 + expect(stdout).toMatch('× test/dont-run-this.test.ts > this will fail') 47 + expect(stdout).toMatch('✓ test/example.test.ts > this will pass') 48 + }) 49 + 50 + test.each([ 51 + { 52 + filter: 'basic', 53 + files: [ 54 + 'test/basic.test.ts', 55 + 'test/foo-basic/a.test.ts', 56 + 'test/basic/a.test.ts', 57 + 'test/basic-foo/a.test.ts', 58 + ], 59 + }, 60 + { 61 + filter: '/basic', 62 + files: [ 63 + 'test/basic.test.ts', 64 + 'test/basic/a.test.ts', 65 + 'test/basic-foo/a.test.ts', 66 + ], 67 + }, 68 + { 69 + filter: 'basic/', 70 + files: [ 71 + 'test/foo-basic/a.test.ts', 72 + 'test/basic/a.test.ts', 73 + ], 74 + }, 75 + { 76 + filter: '/basic/', 77 + files: [ 78 + 'test/basic/a.test.ts', 79 + ], 80 + }, 81 + ])('filter with slash $filter', async ({ filter, files }) => { 82 + const { stdout } = await runVitest({ root: './fixtures/filters-slash' }, [filter]) 83 + expect(stdout).toMatch(`Test Files ${files.length} passed (${files.length})`) 84 + for (const file of files) 85 + expect(stdout).toMatch(`✓ ${file}`) 86 + })
+11
test/core/test/child-specific.child_process.test.ts
··· 1 + import { isMainThread, threadId } from 'node:worker_threads' 2 + import { expect, test } from 'vitest' 3 + 4 + test('has access to child_process API', () => { 5 + expect(process.send).toBeDefined() 6 + }) 7 + 8 + test('doesn\'t have access to threads API', () => { 9 + expect(isMainThread).toBe(true) 10 + expect(threadId).toBe(0) 11 + })
+12
test/core/test/dual-package-hazard.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + // @ts-expect-error no ts 4 + import * as dep1 from '@vitest/test-dep1' 5 + 6 + // @ts-expect-error no ts 7 + import * as dep2 from '@vitest/test-dep2' 8 + 9 + test('no dual package hazard by externalizing esm deps by default', async () => { 10 + dep1.data.hello = 'world' 11 + expect(dep2.data.hello).toBe('world') 12 + })
+21
test/core/test/edge.test.ts
··· 1 + /** 2 + * @vitest-environment edge-runtime 3 + */ 4 + import { describe, expect, it } from 'vitest' 5 + 6 + describe('edge runtime api', () => { 7 + it('TextEncoder references the same global Uint8Array constructor', () => { 8 + expect(new TextEncoder().encode('abc')).toBeInstanceOf(Uint8Array) 9 + }) 10 + 11 + it('allows to run fetch', async () => { 12 + // 3023 is the default port 13 + const response = await fetch('http://localhost:3023/') 14 + expect(response.status).toEqual(200) 15 + }) 16 + 17 + it('allows to run crypto', async () => { 18 + const array = new Uint32Array(10) 19 + expect(crypto.getRandomValues(array)).toHaveLength(array.length) 20 + }) 21 + })
+6
test/core/test/env-glob.dom.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('glob on extension', () => { 4 + expect(typeof window).not.toBe('undefined') 5 + expect(expect.getState().environment).toBe('happy-dom') 6 + })
+6
test/core/test/env-glob.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('default', () => { 4 + expect(typeof window).toBe('undefined') 5 + expect(expect.getState().environment).toBe('node') 6 + })
+6
test/core/test/env.test.ts
··· 73 73 import.meta.env.SSR = false 74 74 expect(import.meta.env.SSR).toEqual(false) 75 75 }) 76 + 77 + test.runIf(process.platform === 'win32')('main process env variables are case insentive', () => { 78 + expect(process.env.PROGRAMFILES).toBeDefined() 79 + expect(process.env['PROGRAMFILES(X86)']).toBeDefined() 80 + expect(process.env['ProgramFiles(x86)']).toBeDefined() 81 + })
+33
test/core/test/module.test.ts
··· 13 13 import * as primitiveAll from '../src/cjs/primitive-cjs' 14 14 15 15 // @ts-expect-error is not typed with imports 16 + import * as prototypeCjs from '../src/cjs/prototype-cjs' 17 + 18 + // @ts-expect-error is not typed with imports 16 19 import * as arrayCjs from '../src/cjs/array-cjs' 17 20 18 21 // @ts-expect-error is not typed with imports ··· 20 23 21 24 // @ts-expect-error is not typed with imports 22 25 import * as nestedDefaultCjs from '../src/cjs/nested-default-cjs' 26 + 27 + import format from '../src/cjs/default-function' 23 28 24 29 // @ts-expect-error is not typed with imports 25 30 import * as nestedDefaultExternalCjs from '../src/external/nested-default-cjs' ··· 29 34 30 35 // @ts-expect-error is not typed with imports 31 36 import * as internalEsm from '../src/esm/internal-esm.mjs' 37 + 38 + // @ts-expect-error is not typed with imports 39 + import * as prototypeEsm from '../src/esm/esm.js' 40 + 32 41 import c, { d } from '../src/module-esm' 33 42 import * as timeout from '../src/timeout' 34 43 ··· 98 107 99 108 it('exports all from native ESM module', () => { 100 109 expect(internalEsm).toHaveProperty('restoreAll') 110 + }) 111 + 112 + it('cjs has object prototype', () => { 113 + expect(prototypeCjs.getPrototype()).toBe(Object.prototype) 114 + expect(() => prototypeCjs.test()).not.toThrow() 115 + expect(prototypeCjs.test()).toBe(true) 116 + }) 117 + 118 + it('esm prototype is null', () => { 119 + expect(Object.getPrototypeOf(prototypeEsm)).toBe(null) 120 + expect({}.hasOwnProperty).toBeTypeOf('function') 121 + 122 + expect(prototypeEsm.hasOwnProperty).toBeTypeOf('undefined') 123 + }) 124 + 125 + describe('correctly puts default on default', () => { 126 + it('works on default function', () => { 127 + expect(format()).toBe('') 128 + }) 129 + 130 + it('works on nested default function', () => { 131 + // @ts-expect-error types defined only default 132 + expect(format.default).toBeUndefined() 133 + }) 101 134 })
+13
test/core/test/resolve-ssr.test.ts
··· 1 + // @vitest-environment node 2 + 3 + import { expect, test } from 'vitest' 4 + import pkgNode from '../src/external/pkg-node' 5 + import pkgBrowser from '../src/external/pkg-browser' 6 + 7 + test('[ssr] resolves to ssr, when node is first in conditions', () => { 8 + expect(pkgNode).toBe('ssr') 9 + }) 10 + 11 + test('[ssr] resolves to ssr, when browser is first in conditions', () => { 12 + expect(pkgBrowser).toBe('ssr') 13 + })
+13
test/core/test/resolve-web.test.ts
··· 1 + // @vitest-environment happy-dom 2 + 3 + import { expect, test } from 'vitest' 4 + import pkgNode from '../src/external/pkg-node' 5 + import pkgBrowser from '../src/external/pkg-browser' 6 + 7 + test('[web] resolves to ssr, when node is first in conditions', () => { 8 + expect(pkgNode).toBe('ssr') 9 + }) 10 + 11 + test('[web] resolves to ssr, when browser is first in conditions', () => { 12 + expect(pkgBrowser).toBe('ssr') 13 + })
+17
test/core/test/snapshot-async.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + function resolve() { 4 + return Promise.resolve('foo') 5 + } 6 + function reject() { 7 + return Promise.reject(new Error('foo')) 8 + } 9 + 10 + test('resolved inline', async () => { 11 + await expect(resolve()).resolves.toMatchInlineSnapshot('"foo"') 12 + }) 13 + 14 + test('rejected inline', async () => { 15 + await expect(reject()).rejects.toMatchInlineSnapshot('[Error: foo]') 16 + await expect(reject()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: foo]`) 17 + })
+10
test/core/test/snapshot-concurrent-sync.test.ts
··· 1 + import { describe, it } from 'vitest' 2 + 3 + // from https://github.com/vitest-dev/vitest/issues/3361 4 + describe.concurrent('concurrent suite', () => { 5 + it('snapshot', ({ expect }) => { 6 + expect({ foo: 'bar' }).toMatchSnapshot() 7 + }) 8 + 9 + it('empty test') 10 + })
+15
test/core/test/snapshot-concurrent.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + const data = [ 4 + 'one', 5 + 'two', 6 + 'three', 7 + 'four', 8 + ] 9 + 10 + data.forEach((i) => { 11 + test.concurrent(i, async ({ expect }) => { 12 + await new Promise(resolve => setTimeout(resolve, Math.random() * 100)) 13 + expect(i).toMatchSnapshot() 14 + }) 15 + })
+20
test/core/test/snapshot-file.test.ts
··· 1 + import { describe, expect, test } from 'vitest' 2 + 3 + function objectToCSS(selector: string, obj: Record<string, string>) { 4 + const body = Object.entries(obj) 5 + .map(([key, value]) => ` ${key}: ${value};`) 6 + .join('\n') 7 + return `${selector} {\n${body}\n}` 8 + } 9 + 10 + describe('snapshots', () => { 11 + const files = import.meta.glob('./fixtures/snapshots/**/input.json', { as: 'raw' }) 12 + 13 + for (const [path, file] of Object.entries(files)) { 14 + test(path, async () => { 15 + const entries = JSON.parse(await file()) as any[] 16 + expect(entries.map(i => objectToCSS(i[0], i[1])).join('\n')) 17 + .toMatchFileSnapshot(path.replace('input.json', 'output.css')) 18 + }) 19 + } 20 + })
+27
test/core/test/snapshot.test.ts
··· 134 134 } 135 135 `) 136 136 }) 137 + 138 + function println() { 139 + const message = ` 140 + export default function () { 141 + function Foo() { 142 + } 143 + 144 + return Foo; 145 + } 146 + ` 147 + return message 148 + } 149 + 150 + test('multiline strings ', () => { 151 + expect(println()).toMatchSnapshot() 152 + }) 153 + 154 + test('updateInlineSnapshot should not remove end whitespace', () => { 155 + // issue #922 156 + expect(` 157 + my string 158 + `).toMatchInlineSnapshot(` 159 + " 160 + my string 161 + " 162 + `) 163 + })
+11
test/core/test/threads-specific.threads.test.ts
··· 1 + import { isMainThread, threadId } from 'node:worker_threads' 2 + import { expect, test } from 'vitest' 3 + 4 + test('has access access to worker API', () => { 5 + expect(isMainThread).toBe(false) 6 + expect(threadId).toBeGreaterThan(0) 7 + }) 8 + 9 + test('doesn\'t have access access to child_process API', () => { 10 + expect(process.send).toBeUndefined() 11 + })
+93
test/core/test/utils-display.spec.ts
··· 1 + import util from 'node:util' 2 + import { describe, expect, test } from 'vitest' 3 + import { format } from '@vitest/utils' 4 + 5 + describe('format', () => { 6 + const obj = {} as any 7 + obj.obj = obj 8 + 9 + test.each([ 10 + [''], 11 + ['test'], 12 + [{ obj: { nested: true }, value: 1 }], 13 + ['test %s', 'test'], 14 + ['test %s %s', 'test', 'test'], 15 + ['test %s %s', 'test', 'test', 'test'], 16 + ['%s', 100], 17 + ['%s', 100n], 18 + ['%s', -0], 19 + ['%s', null], 20 + ['%s', null, 'next'], 21 + ['%d', 100], 22 + ['%d', 100n], 23 + ['%d', null], 24 + ['%d', {}], 25 + ['%d', {}, 'next'], 26 + ['%i', 100], 27 + ['%i', 100n], 28 + ['%i', null], 29 + ['%i', {}], 30 + ['%i', {}, 'next'], 31 + ['%f', 100], 32 + ['%f', 100n], 33 + ['%f', null], 34 + ['%f', {}], 35 + ['%f', {}, 'next'], 36 + ['%o', 'string'], 37 + ['%o', 100], 38 + ['%o', 100n], 39 + ['%o', null], 40 + ['%o', {}], 41 + ['%o', {}, 'next'], 42 + ['%O', 'string'], 43 + ['%O', 100], 44 + ['%O', 100n], 45 + ['%O', null], 46 + ['%O', {}], 47 + ['%O', {}, 'next'], 48 + ['%c', 'css value'], 49 + ['%c', 'css value', 'some other value'], 50 + ['%c %f', 'css value', '100.00'], 51 + ['%j', 'string'], 52 + ['%j', 100], 53 + ['%j', null], 54 + ['%j', {}], 55 + ['%j', {}, 'next'], 56 + ['%j', { obj }], 57 + ['%j', { fn: () => {} }], 58 + ['%%', 'string'], 59 + ])('format(%s)', (formatString, ...args) => { 60 + expect(format(formatString, ...args), `failed ${formatString}`).toBe(util.format(formatString, ...args)) 61 + }) 62 + 63 + test('cannont serialize some values', () => { 64 + expect(() => format('%j', 100n)).toThrowErrorMatchingInlineSnapshot(`[TypeError: Do not know how to serialize a BigInt]`) 65 + }) 66 + 67 + test.each( 68 + [ 69 + { 70 + name: 'without format', 71 + args: [{ n: { a: { b: { c: { d: { e: '3' } } } } } }], 72 + result: '{ n: { a: { b: { c: { d: { e: \'3\' } } } } } }', 73 + }, 74 + { 75 + name: 'as an object', 76 + args: ['%o', {}, { n: { a: { b: { c: '3' } } } }], 77 + result: '{} { n: { a: { b: { c: \'3\' } } } }', 78 + }, 79 + { 80 + name: 'as a full object', 81 + args: ['%O', {}, { n: { a: { b: { c: '3' } } } }], 82 + result: '{} { n: { a: { b: { c: \'3\' } } } }', 83 + }, 84 + { 85 + name: 'as a json', 86 + args: ['%j', {}, { n: { a: { b: { c: '3' } } } }], 87 + result: '{} { n: { a: { b: { c: \'3\' } } } }', 88 + }, 89 + ], 90 + )('formats objects $name (loupe doesn\'t respect depth)', ({ args, result }) => { 91 + expect(format(...args)).toBe(result) 92 + }) 93 + })
+89
test/core/test/wasm.test.ts
··· 1 + import { readFileSync } from 'node:fs' 2 + import { resolve } from 'node:path' 3 + import { expect, test, vi } from 'vitest' 4 + 5 + // @ts-expect-error wasm is not typed 6 + import { add } from '../src/wasm/add.wasm' 7 + 8 + const wasmFileBuffer = readFileSync(resolve(__dirname, '../src/wasm/add.wasm')) 9 + 10 + test('supports native wasm imports', () => { 11 + expect(add(1, 2)).toBe(3) 12 + 13 + // because arguments are i32 (signed), fractional part is truncated 14 + expect(add(0.99, 1.01)).toBe(1) 15 + 16 + // because return value is i32 (signed), (2^31 - 1) + 1 overflows and becomes -2^31 17 + expect(add(2 ** 31 - 1, 1)).toBe(-(2 ** 31)) 18 + 19 + // invalid or missing arguments are treated as 0 20 + expect(add('hello', 'world')).toBe(0) 21 + expect(add()).toBe(0) 22 + expect(add(null)).toBe(0) 23 + expect(add({}, [])).toBe(0) 24 + 25 + // redundant arguments are silently ignored 26 + expect(add(1, 2, 3)).toBe(3) 27 + }) 28 + 29 + test('supports dynamic wasm imports', async () => { 30 + // @ts-expect-error wasm is not typed 31 + const { add: dynamicAdd } = await import('../src/wasm/add.wasm') 32 + expect(dynamicAdd(1, 2)).toBe(3) 33 + }) 34 + 35 + test('supports imports from "data:application/wasm" URI with base64 encoding', async () => { 36 + const importedWasmModule = await import( 37 + `data:application/wasm;base64,${wasmFileBuffer.toString('base64')}` 38 + ) 39 + expect(importedWasmModule.add(0, 42)).toBe(42) 40 + }) 41 + 42 + // TODO: error message is different on vm 43 + const isVm = process.execArgv.includes('--experimental-vm-modules') 44 + 45 + test('imports from "data:application/wasm" URI without explicit encoding fail', async () => { 46 + const error = await getError(() => import(`data:application/wasm,${wasmFileBuffer.toString('base64')}`)) 47 + if (isVm) 48 + expect(error).toMatchInlineSnapshot(`[Error: Missing data URI encoding]`) 49 + else 50 + expect(error).toMatchInlineSnapshot(`[CompileError: data:application/wasm,AGFzbQEAAAABBwFgAn9/AX8DAgEABwcBA2FkZAAACgkBBwAgACABags=: WebAssembly.compile(): expected magic word 00 61 73 6d, found 41 47 46 7a @+0]`) 51 + }) 52 + 53 + test('imports from "data:application/wasm" URI with invalid encoding fail', async () => { 54 + // @ts-expect-error import is not typed 55 + const error = await getError(() => import('data:application/wasm;charset=utf-8,oops')) 56 + if (isVm) 57 + expect(error).toMatchInlineSnapshot(`[Error: Invalid data URI encoding: charset=utf-8]`) 58 + else 59 + expect(error).toMatchInlineSnapshot(`[CompileError: data:application/wasm;charset=utf-8,oops: WebAssembly.compile(): expected magic word 00 61 73 6d, found 6f 6f 70 73 @+0]`) 60 + }) 61 + 62 + async function getError(f: () => unknown) { 63 + try { 64 + await f() 65 + } 66 + catch (e) { 67 + return e 68 + } 69 + expect.unreachable() 70 + } 71 + 72 + test('supports wasm/js cyclic import (old wasm-bindgen output)', async () => { 73 + globalThis.alert = vi.fn() 74 + 75 + // @ts-expect-error not typed 76 + const { greet } = await import('../src/wasm/wasm-bindgen/index.js') 77 + greet('World') 78 + 79 + expect(globalThis.alert).toHaveBeenCalledWith('Hello, World!') 80 + }) 81 + 82 + test('supports wasm-bindgen', async () => { 83 + globalThis.alert = vi.fn() 84 + 85 + const { greet } = await import('../src/wasm/wasm-bindgen-no-cyclic/index.js') 86 + greet('No Cyclic') 87 + 88 + expect(globalThis.alert).toHaveBeenCalledWith('Hello, No Cyclic!') 89 + })
+35
test/core/test/web-worker-jsdom.test.ts
··· 1 + // @vitest-environment jsdom 2 + 3 + import '@vitest/web-worker' 4 + 5 + import { expect, it } from 'vitest' 6 + 7 + it('worker with invalid url throws an error', async () => { 8 + const url = import.meta.url 9 + const worker = new Worker(new URL('../src/web-worker/workerInvalid-path.ts', url)) 10 + const event = await new Promise<ErrorEvent>((resolve) => { 11 + worker.onerror = (e) => { 12 + resolve(e) 13 + } 14 + }) 15 + expect(event).toBeInstanceOf(ErrorEvent) 16 + // Error is in different context when running in VM. This is consistent with jest. 17 + if (!import.meta.env.VITEST_VM_POOL) 18 + expect(event.error).toBeInstanceOf(Error) 19 + expect(event.error.message).toContain('Failed to load') 20 + }) 21 + 22 + it('throws an error on invalid path', async () => { 23 + expect(SharedWorker).toBeDefined() 24 + const worker = new SharedWorker('./web-worker/some-invalid-path') 25 + const event = await new Promise<ErrorEvent>((resolve) => { 26 + worker.onerror = (e) => { 27 + resolve(e) 28 + } 29 + }) 30 + expect(event).toBeInstanceOf(ErrorEvent) 31 + // Error is in different context when running in VM. This is consistent with jest. 32 + if (!import.meta.env.VITEST_VM_POOL) 33 + expect(event.error).toBeInstanceOf(Error) 34 + expect(event.error.message).toContain('Failed to load') 35 + })
+271
test/core/test/web-worker-node.test.ts
··· 1 + // @vitest-environment node 2 + 3 + import '@vitest/web-worker' 4 + 5 + import { version } from 'node:process' 6 + import { beforeEach, describe, expect, it, vi } from 'vitest' 7 + 8 + import MyWorker from '../src/web-worker/worker?worker' 9 + import MyObjectWorker from '../src/web-worker/objectWorker?worker' 10 + import MyEventListenerWorker from '../src/web-worker/eventListenerWorker?worker' 11 + import MySelfWorker from '../src/web-worker/selfWorker?worker' 12 + import MySharedWorker from '../src/web-worker/sharedWorker?sharedworker' 13 + 14 + const major = Number(version.split('.')[0].slice(1)) 15 + 16 + describe.runIf(major >= 17)('when node supports structuredClone', () => { 17 + it('uses native structure clone', () => { 18 + expect.assertions(4) 19 + 20 + expect(structuredClone).toBeDefined() 21 + 22 + const worker = new MyObjectWorker() 23 + const buffer = new ArrayBuffer(1) 24 + const obj = { hello: 'world', buffer } 25 + worker.postMessage(obj, [buffer]) 26 + 27 + return new Promise<void>((resolve, reject) => { 28 + worker.onmessage = (e) => { 29 + try { 30 + expect(e).toBeInstanceOf(MessageEvent) 31 + expect(e.data, 'doesn\'t keep reference').not.toBe(obj) 32 + expect(e.data, 'shape is equal').toEqual(obj) 33 + resolve() 34 + } 35 + catch (err) { 36 + reject(err) 37 + } 38 + finally { 39 + worker.terminate() 40 + } 41 + } 42 + }) 43 + }) 44 + 45 + it('throws error, if passing down unserializable data', () => { 46 + expect.assertions(4) 47 + 48 + expect(structuredClone).toBeDefined() 49 + 50 + const worker = new MyObjectWorker() 51 + const obj = { hello: 'world', name() {} } 52 + worker.postMessage(obj) 53 + 54 + return new Promise<void>((resolve, reject) => { 55 + worker.onmessageerror = (e) => { 56 + try { 57 + expect(e.type).toBe('messageerror') 58 + expect(e).toBeInstanceOf(MessageEvent) 59 + expect(e.data.message).toContain( 60 + 'could not be cloned.', 61 + ) 62 + resolve() 63 + } 64 + catch (err) { 65 + reject(err) 66 + } 67 + } 68 + }) 69 + }) 70 + }) 71 + 72 + describe('when passing down custom clone', () => { 73 + const { warn } = console 74 + 75 + beforeEach(() => { 76 + console.warn = warn 77 + process.env.VITEST_WEB_WORKER_CLONE = undefined 78 + }) 79 + 80 + it('uses ponyfill clone', () => { 81 + expect.assertions(4) 82 + 83 + console.warn = vi.fn() 84 + process.env.VITEST_WEB_WORKER_CLONE = 'ponyfill' 85 + 86 + const worker = new MyObjectWorker() 87 + const buffer = new ArrayBuffer(1) 88 + const obj = { hello: 'world' } 89 + worker.postMessage(obj, [buffer]) 90 + 91 + return new Promise<void>((resolve, reject) => { 92 + worker.onmessageerror = (e) => { 93 + reject(e.data) 94 + } 95 + worker.onmessage = (e) => { 96 + try { 97 + expect(e).toBeInstanceOf(MessageEvent) 98 + expect(e.data, 'doesn\'t keep reference').not.toBe(obj) 99 + expect(e.data, 'shape is not equal, don\'t transfer buffer').toEqual({ hello: 'world' }) 100 + expect(console.warn).toBeCalledWith(expect.stringContaining('[@vitest/web-worker] `structuredClone` is not supported in this')) 101 + resolve() 102 + } 103 + catch (err) { 104 + reject(err) 105 + } 106 + finally { 107 + worker.terminate() 108 + } 109 + } 110 + }) 111 + }) 112 + 113 + it('doesn\'t clone, if asked to', () => { 114 + expect.assertions(3) 115 + 116 + console.warn = vi.fn() 117 + process.env.VITEST_WEB_WORKER_CLONE = 'none' 118 + 119 + const worker = new MyObjectWorker() 120 + const buffer = new ArrayBuffer(1) 121 + const obj = { hello: 'world', buffer } 122 + worker.postMessage(obj, [buffer]) 123 + 124 + return new Promise<void>((resolve, reject) => { 125 + worker.onmessageerror = (e) => { 126 + reject(e.data) 127 + } 128 + worker.onmessage = (e) => { 129 + try { 130 + expect(e).toBeInstanceOf(MessageEvent) 131 + expect(e.data, 'keeps reference').toBe(obj) 132 + expect(console.warn).not.toHaveBeenCalled() 133 + resolve() 134 + } 135 + catch (err) { 136 + reject(err) 137 + } 138 + finally { 139 + worker.terminate() 140 + } 141 + } 142 + }) 143 + }) 144 + }) 145 + 146 + function sleep(time: number) { 147 + return new Promise(resolve => setTimeout(resolve, time)) 148 + } 149 + 150 + function testWorker(worker: Worker) { 151 + return new Promise<void>((resolve) => { 152 + worker.postMessage('hello') 153 + worker.onmessage = (e) => { 154 + expect(e.data).toBe('hello world') 155 + 156 + resolve() 157 + } 158 + }) 159 + } 160 + 161 + function testSelfWorker(worker: Worker) { 162 + return new Promise<boolean>((resolve) => { 163 + worker.onmessage = (e) => { 164 + resolve(e.data) 165 + } 166 + }) 167 + } 168 + 169 + it('worker exists', async () => { 170 + expect(Worker).toBeDefined() 171 + }) 172 + 173 + it('simple worker', async () => { 174 + expect.assertions(1) 175 + 176 + await testWorker(new MyWorker()) 177 + }) 178 + 179 + it('event listener worker', async () => { 180 + expect.assertions(1) 181 + 182 + await testWorker(new MyEventListenerWorker()) 183 + }) 184 + 185 + it('can test workers several times', async () => { 186 + expect.assertions(1) 187 + 188 + await testWorker(new MyWorker()) 189 + }) 190 + 191 + it('worker with url', async () => { 192 + expect.assertions(1) 193 + const url = import.meta.url 194 + 195 + await testWorker(new Worker(new URL('../src/web-worker/worker.ts', url))) 196 + }) 197 + 198 + it('self injected into worker and its deps should be equal', async () => { 199 + expect.assertions(4) 200 + expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() 201 + // wait for clear worker mod cache 202 + await sleep(0) 203 + expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() 204 + 205 + await sleep(0) 206 + 207 + expect(await testSelfWorker(new Worker(new URL('../src/web-worker/selfWorker.ts', import.meta.url)))).toBeTruthy() 208 + // wait for clear worker mod cache 209 + await sleep(0) 210 + expect(await testSelfWorker(new Worker(new URL('../src/web-worker/selfWorker.ts', import.meta.url)))).toBeTruthy() 211 + }) 212 + 213 + it('throws syntax error if no arguments are provided', () => { 214 + const worker = new MyWorker() 215 + 216 + // @ts-expect-error requires at least one argument 217 + expect(() => worker.postMessage()).toThrowError(SyntaxError) 218 + expect(() => worker.postMessage(undefined)).not.toThrowError() 219 + expect(() => worker.postMessage(null)).not.toThrowError() 220 + }) 221 + 222 + function sendEventMessage(worker: SharedWorker, msg: any) { 223 + worker.port.postMessage(msg) 224 + return new Promise<string>((resolve) => { 225 + worker.port.addEventListener('message', function onmessage(e) { 226 + worker.port.removeEventListener('message', onmessage) 227 + resolve(e.data as string) 228 + }) 229 + }) 230 + } 231 + 232 + function sendOnMessage(worker: SharedWorker, msg: any) { 233 + worker.port.postMessage(msg) 234 + return new Promise<string>((resolve) => { 235 + worker.port.onmessage = function onmessage(e) { 236 + worker.port.onmessage = null 237 + resolve(e.data as string) 238 + } 239 + }) 240 + } 241 + 242 + it('vite shared worker works', async () => { 243 + expect(MySharedWorker).toBeDefined() 244 + expect(SharedWorker).toBeDefined() 245 + const worker = new MySharedWorker() 246 + expect(worker).toBeInstanceOf(SharedWorker) 247 + 248 + await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') 249 + await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') 250 + }) 251 + 252 + it('shared worker with path works', async () => { 253 + expect(SharedWorker).toBeDefined() 254 + const worker = new SharedWorker(new URL('../src/web-worker/sharedWorker.ts', import.meta.url)) 255 + expect(worker).toBeTruthy() 256 + 257 + await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') 258 + await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') 259 + }) 260 + 261 + it('doesn\'t trigger events, if closed', async () => { 262 + const worker = new MySharedWorker() 263 + worker.port.close() 264 + await new Promise((resolve) => { 265 + worker.port.addEventListener('message', () => { 266 + expect.fail('should not trigger message') 267 + }) 268 + worker.port.postMessage('event') 269 + setTimeout(resolve, 100) 270 + }) 271 + })
+41
test/core/vitest-environment-custom/index.ts
··· 1 + import vm from 'node:vm' 2 + import debug from 'debug' 3 + import type { Environment } from 'vitest' 4 + 5 + // test that external packages (debug) are loaded correctly 6 + const log = debug('test:env') 7 + 8 + export default <Environment>{ 9 + name: 'custom', 10 + transformMode: 'ssr', 11 + setupVM({ custom }) { 12 + const context = vm.createContext({ 13 + testEnvironment: 'custom', 14 + option: custom.option, 15 + setTimeout, 16 + clearTimeout, 17 + }) 18 + return { 19 + getVmContext() { 20 + return context 21 + }, 22 + teardown() { 23 + delete context.testEnvironment 24 + delete context.option 25 + }, 26 + } 27 + }, 28 + setup(global, { custom }) { 29 + global.testEnvironment = 'custom' 30 + global.option = custom.option 31 + return { 32 + teardown() { 33 + delete global.testEnvironment 34 + delete global.option 35 + 36 + if (global.__exists) 37 + log('should not log') 38 + }, 39 + } 40 + }, 41 + }
+8
test/core/vitest-environment-custom/package.json
··· 1 + { 2 + "name": "vitest-environment-custom", 3 + "private": true, 4 + "exports": { 5 + ".": "./index.ts" 6 + }, 7 + "main": "index.ts" 8 + }
-4
test/css/src/App.css
··· 1 - .main { 2 - display: flex; 3 - width: 100px; 4 - }
-7
test/css/src/App.module.css
··· 1 - .main { 2 - display: flex; 3 - } 4 - 5 - .module { 6 - width: 100px; 7 - }
-38
test/css/test/default-css.spec.ts
··· 1 - import { describe, expect, test } from 'vitest' 2 - import { useRemoveStyles } from './utils' 3 - 4 - describe('don\'t process css by default', () => { 5 - useRemoveStyles() 6 - 7 - test('doesn\'t apply css', async () => { 8 - await import('../src/App.css') 9 - 10 - const element = document.createElement('div') 11 - element.className = 'main' 12 - const computed = window.getComputedStyle(element) 13 - expect(computed.display).toBe('block') 14 - expect(element).toMatchInlineSnapshot(` 15 - <div 16 - class="main" 17 - /> 18 - `) 19 - }) 20 - 21 - test('module is not processed', async () => { 22 - const { default: styles } = await import('../src/App.module.css') 23 - 24 - // HASH is static, based on the filepath to root 25 - expect(styles.module).toBe('_module_6dc87e') 26 - expect(styles.someRandomValue).toBe('_someRandomValue_6dc87e') 27 - const element = document.createElement('div') 28 - element.className = '_module_6dc87e' 29 - const computed = window.getComputedStyle(element) 30 - expect(computed.display).toBe('block') 31 - expect(computed.width).toBe('') 32 - expect(element).toMatchInlineSnapshot(` 33 - <div 34 - class="_module_6dc87e" 35 - /> 36 - `) 37 - }) 38 - })
-18
test/css/test/non-scope-module.spec.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('module is processed', async () => { 4 - const { default: styles } = await import('../src/App.module.css') 5 - 6 - expect(styles.module).toBe('module') 7 - expect(styles.someRandomValue).toBeUndefined() 8 - const element = document.createElement('div') 9 - element.className = `${styles.main} ${styles.module}` 10 - const computed = window.getComputedStyle(element) 11 - expect(computed.display).toBe('flex') 12 - expect(computed.width).toBe('100px') 13 - expect(element).toMatchInlineSnapshot(` 14 - <div 15 - class="main module" 16 - /> 17 - `) 18 - })
-37
test/css/test/process-css.spec.ts
··· 1 - import { describe, expect, test } from 'vitest' 2 - import { useRemoveStyles } from './utils' 3 - 4 - describe('process only css, not module css', () => { 5 - useRemoveStyles() 6 - 7 - test('apply css', async () => { 8 - await import('../src/App.css') 9 - 10 - const element = document.createElement('div') 11 - element.className = 'main' 12 - const computed = window.getComputedStyle(element) 13 - expect(computed.display).toBe('flex') 14 - expect(element).toMatchInlineSnapshot(` 15 - <div 16 - class="main" 17 - /> 18 - `) 19 - }) 20 - 21 - test('module is not processed', async () => { 22 - const { default: styles } = await import('../src/App.module.css') 23 - 24 - expect(styles.module).toBe('_module_6dc87e') 25 - expect(styles.someRandomValue).toBe('_someRandomValue_6dc87e') 26 - const element = document.createElement('div') 27 - element.className = '_module_6dc87e' 28 - const computed = window.getComputedStyle(element) 29 - expect(computed.display).toBe('block') 30 - expect(computed.width).toBe('') 31 - expect(element).toMatchInlineSnapshot(` 32 - <div 33 - class="_module_6dc87e" 34 - /> 35 - `) 36 - }) 37 - })
-20
test/css/test/process-inline.spec.ts
··· 1 - import { describe, expect, test } from 'vitest' 2 - import { useRemoveStyles } from './utils' 3 - 4 - describe('processing inline css', () => { 5 - useRemoveStyles() 6 - 7 - test('doesn\'t apply css', async () => { 8 - await import('../src/App.module.css?inline') 9 - 10 - const element = document.createElement('div') 11 - element.className = 'main' 12 - const computed = window.getComputedStyle(element) 13 - expect(computed.display, 'css is not processed').toBe('block') 14 - }) 15 - 16 - test('returns a string', async () => { 17 - const { default: style } = await import('../src/App.module.css?inline') 18 - expect(typeof style).toBe('string') 19 - }) 20 - })
-32
test/css/test/process-module.spec.ts
··· 1 - import { describe, expect, test } from 'vitest' 2 - import { useRemoveStyles } from './utils' 3 - 4 - describe('processing module css', () => { 5 - useRemoveStyles() 6 - 7 - test('doesn\'t apply css', async () => { 8 - await import('../src/App.css') 9 - 10 - const element = document.createElement('div') 11 - element.className = 'main' 12 - const computed = window.getComputedStyle(element) 13 - expect(computed.display, 'css is not processed').toBe('block') 14 - }) 15 - 16 - test('module is processed', async () => { 17 - const { default: styles } = await import('../src/App.module.css') 18 - 19 - expect(styles.module).toBe('_module_6dc87e') 20 - expect(styles.someRandomValue).toBeUndefined() 21 - const element = document.createElement('div') 22 - element.className = '_main_6dc87e _module_6dc87e' 23 - const computed = window.getComputedStyle(element) 24 - expect(computed.display, 'css is processed').toBe('flex') 25 - expect(computed.width).toBe('100px') 26 - expect(element).toMatchInlineSnapshot(` 27 - <div 28 - class="_main_6dc87e _module_6dc87e" 29 - /> 30 - `) 31 - }) 32 - })
-30
test/css/test/scope-module.spec.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('module is processed and scoped', async () => { 4 - const { default: styles } = await import('../src/App.module.css') 5 - 6 - expect(styles.module).toMatch(/_module_\w+_\w/) 7 - expect(styles.someRandomValue).toBeUndefined() 8 - const element = document.createElement('div') 9 - element.className = 'module main' 10 - const computedStatic = window.getComputedStyle(element) 11 - expect(computedStatic.display).toBe('block') 12 - expect(computedStatic.width).toBe('') 13 - expect(element).toMatchInlineSnapshot(` 14 - <div 15 - class="module main" 16 - /> 17 - `) 18 - 19 - const mangledElement = document.createElement('div') 20 - 21 - mangledElement.className = `${styles.module} ${styles.main}` 22 - const computedModules = window.getComputedStyle(mangledElement) 23 - expect(computedModules.display).toBe('flex') 24 - expect(computedModules.width).toBe('100px') 25 - expect(mangledElement).toMatchInlineSnapshot(` 26 - <div 27 - class="_module_19cso_5 _main_19cso_1" 28 - /> 29 - `) 30 - })
-13
test/css/test/utils.ts
··· 1 - import { afterEach, beforeEach } from 'vitest' 2 - 3 - function removeStyles() { 4 - document.head.querySelectorAll('style').forEach(style => style.remove()) 5 - } 6 - export function useRemoveStyles() { 7 - beforeEach(() => removeStyles()) 8 - afterEach(() => removeStyles()) 9 - 10 - return { 11 - removeStyles, 12 - } 13 - }
-20
test/edge-runtime/test/edge.test.ts
··· 1 - /** 2 - * @vitest-environment edge-runtime 3 - */ 4 - import { describe, expect, it } from 'vitest' 5 - 6 - describe('edge runtime api', () => { 7 - it('TextEncoder references the same global Uint8Array constructor', () => { 8 - expect(new TextEncoder().encode('abc')).toBeInstanceOf(Uint8Array) 9 - }) 10 - 11 - it('allows to run fetch', async () => { 12 - const response = await fetch('https://github.com/robots.txt') 13 - expect(response.status).toEqual(200) 14 - }) 15 - 16 - it('allows to run crypto', async () => { 17 - const array = new Uint32Array(10) 18 - expect(crypto.getRandomValues(array)).toHaveLength(array.length) 19 - }) 20 - })
test/empty-test/test/empty.test.ts
-3
test/empty-test/test/one.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('two', () => expect(1 + 1).toBe(2))
-7
test/env-custom-file/test/base.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('custom env is defined', () => { 4 - expect(expect.getState().environment).toBe('custom') 5 - expect((globalThis as any).testEnvironment).toBe('custom') 6 - expect((globalThis as any).option).toBe('config-option') 7 - })
-7
test/env-custom/test/base.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('custom env is defined', () => { 4 - expect(expect.getState().environment).toBe('custom') 5 - expect((globalThis as any).testEnvironment).toBe('custom') 6 - expect((globalThis as any).option).toBe('config-option') 7 - })
-41
test/env-custom/vitest-environment-custom/index.ts
··· 1 - import vm from 'node:vm' 2 - import debug from 'debug' 3 - import type { Environment } from 'vitest' 4 - 5 - // test that external packages (debug) are loaded correctly 6 - const log = debug('test:env') 7 - 8 - export default <Environment>{ 9 - name: 'custom', 10 - transformMode: 'ssr', 11 - setupVM({ custom }) { 12 - const context = vm.createContext({ 13 - testEnvironment: 'custom', 14 - option: custom.option, 15 - setTimeout, 16 - clearTimeout, 17 - }) 18 - return { 19 - getVmContext() { 20 - return context 21 - }, 22 - teardown() { 23 - delete context.testEnvironment 24 - delete context.option 25 - }, 26 - } 27 - }, 28 - setup(global, { custom }) { 29 - global.testEnvironment = 'custom' 30 - global.option = custom.option 31 - return { 32 - teardown() { 33 - delete global.testEnvironment 34 - delete global.option 35 - 36 - if (global.__exists) 37 - log('should not log') 38 - }, 39 - } 40 - }, 41 - }
-8
test/env-custom/vitest-environment-custom/package.json
··· 1 - { 2 - "name": "vitest-environment-custom", 3 - "private": true, 4 - "exports": { 5 - ".": "./index.ts" 6 - }, 7 - "main": "index.ts" 8 - }
-6
test/env-glob/test/base.dom.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('glob on extension', () => { 4 - expect(typeof window).not.toBe('undefined') 5 - expect(expect.getState().environment).toBe('happy-dom') 6 - })
-6
test/env-glob/test/base.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('default', () => { 4 - expect(typeof window).toBe('undefined') 5 - expect(expect.getState().environment).toBe('node') 6 - })
-5
test/env-mixed/fixtures/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: {}, 5 - })
-21
test/env-mixed/fixtures/vitest.workspace.ts
··· 1 - import { resolve } from 'node:path' 2 - import { fileURLToPath } from 'node:url' 3 - import { defineWorkspace } from 'vitest/config' 4 - 5 - const __filename = fileURLToPath(import.meta.url) 6 - const __dirname = resolve(__filename, '..') 7 - 8 - export default defineWorkspace([ 9 - { 10 - test: { 11 - name: 'Project #1', 12 - root: resolve(__dirname, './project'), 13 - }, 14 - }, 15 - { 16 - test: { 17 - name: 'Project #2', 18 - root: resolve(__dirname, './project'), 19 - }, 20 - }, 21 - ])
-27
test/env-mixed/test/mixed-environments.test.ts
··· 1 - import { type UserConfig, expect, test } from 'vitest' 2 - 3 - import { runVitest } from '../../test-utils' 4 - 5 - const configs: UserConfig[] = [ 6 - { pool: 'threads', poolOptions: { threads: { isolate: false, singleThread: true } } }, 7 - { pool: 'threads', poolOptions: { threads: { isolate: false, singleThread: false } } }, 8 - { pool: 'threads', poolOptions: { threads: { isolate: false, minThreads: 1, maxThreads: 1 } } }, 9 - { pool: 'forks', poolOptions: { forks: { isolate: true } } }, 10 - { pool: 'forks', poolOptions: { forks: { isolate: false } } }, 11 - ] 12 - 13 - test.each(configs)('should isolate environments when %s', async (config) => { 14 - const { stderr, stdout } = await runVitest({ 15 - root: './fixtures', 16 - ...config, 17 - }) 18 - 19 - expect(stderr).toBe('') 20 - 21 - expect(stdout).toContain('✓ test/node.test.ts') 22 - expect(stdout).toContain('✓ test/jsdom.test.ts') 23 - expect(stdout).toContain('✓ test/happy-dom.test.ts') 24 - expect(stdout).toContain('✓ test/workspace-project.test.ts') 25 - expect(stdout).toContain('Test Files 8 passed (8)') 26 - expect(stdout).toContain('Tests 8 passed (8)') 27 - })
-1
test/esm/src/prototype.d.mts
··· 1 - declare export const test: number
-1
test/esm/src/prototype.mjs
··· 1 - export const test = 1
-9
test/esm/test/executes.spec.ts
··· 1 - import { __assign } from 'tslib' 2 - import { parse } from 'css-what' 3 - import { expect, test } from 'vitest' 4 - 5 - // TODO check on Linux Node 14 6 - test.skip('imported libs have incorrect ESM, but still work', () => { 7 - expect(__assign({}, { a: 1 })).toEqual({ a: 1 }) 8 - expect(parse('a')).toBeDefined() 9 - })
-9
test/esm/test/prototype.spec.ts
··· 1 - import { expect, it } from 'vitest' 2 - import * as exports from '../src/prototype.mjs' 3 - 4 - it('prototype is null', () => { 5 - expect(Object.getPrototypeOf(exports)).toBe(null) 6 - expect({}.hasOwnProperty).toBeTypeOf('function') 7 - 8 - expect(exports.hasOwnProperty).toBeTypeOf('undefined') 9 - })
-12
test/failing/fixtures/vite.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - pool: 'forks', 6 - poolOptions: { 7 - forks: { 8 - isolate: false, 9 - }, 10 - }, 11 - }, 12 - })
-54
test/failing/test/expect.test.ts
··· 1 - import { resolve } from 'node:path' 2 - import type { UserConfig } from 'vitest' 3 - import { describe, expect, test } from 'vitest' 4 - import { getCurrentTest } from '@vitest/runner' 5 - import { runVitest } from '../../test-utils' 6 - 7 - describe('expect.soft', () => { 8 - const run = (config?: UserConfig) => runVitest({ root: resolve('./fixtures'), include: ['expects/soft.test.ts'], setupFiles: [], testNamePattern: getCurrentTest()?.name, testTimeout: 4000, ...config }, ['soft']) 9 - 10 - test('basic', async () => { 11 - const { stderr } = await run() 12 - expect.soft(stderr).toContain('AssertionError: expected 1 to be 2') 13 - expect.soft(stderr).toContain('AssertionError: expected 2 to be 3') 14 - }) 15 - 16 - test('promise', async () => { 17 - const { stderr } = await run() 18 - expect.soft(stderr).toContain('AssertionError: expected 2 to be 3') 19 - expect.soft(stderr).toContain('AssertionError: expected 1 to be 2') 20 - }) 21 - 22 - test('with expect', async () => { 23 - const { stderr } = await run() 24 - expect.soft(stderr).toContain('AssertionError: expected 1 to deeply equal 2') 25 - expect.soft(stderr).toContain('AssertionError: expected 10 to deeply equal 20') 26 - expect.soft(stderr).not.toContain('AssertionError: expected 2 to deeply equal 3') 27 - }) 28 - 29 - test('with expect.extend', async () => { 30 - const { stderr } = await run() 31 - expect.soft(stderr).toContain('AssertionError: expected 1 to deeply equal 2') 32 - expect.soft(stderr).toContain('Error: expected 3 to be divisible by 4') 33 - expect.soft(stderr).toContain('AssertionError: expected 5 to deeply equal 6') 34 - }) 35 - 36 - test('passed', async () => { 37 - const { stdout } = await run() 38 - expect.soft(stdout).toContain('soft.test.ts > passed') 39 - }) 40 - 41 - test('retry will passed', async () => { 42 - const { stdout } = await run() 43 - expect.soft(stdout).toContain('soft.test.ts > retry will passed') 44 - }) 45 - 46 - test('retry will failed', async () => { 47 - const { stderr } = await run() 48 - expect.soft(stderr).toContain('AssertionError: expected 1 to be 4') 49 - expect.soft(stderr).toContain('AssertionError: expected 2 to be 5') 50 - expect.soft(stderr).toContain('AssertionError: expected 3 to be 4') 51 - expect.soft(stderr).toContain('AssertionError: expected 4 to be 5') 52 - expect.soft(stderr).toContain('4/4') 53 - }) 54 - }, 4000)
-5
test/fails/fixtures/each-timeout.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test.each([1])('test each timeout', async () => { 4 - await new Promise(resolve => setTimeout(resolve, 20)) 5 - }, 10)
test/fails/fixtures/empty.test.ts
-3
test/fails/fixtures/expect-soft.test.ts
··· 1 - import { expect } from 'vitest' 2 - 3 - expect.soft(1 + 1).toEqual(3)
-5
test/fails/fixtures/expect-unreachable.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('', () => { 4 - expect.unreachable('hi') 5 - })
-5
test/fails/fixtures/expect.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('hi', () => { 4 - expect(1 + 1).toEqual(3) 5 - })
-10
test/fails/fixtures/hook-timeout.test.ts
··· 1 - import { beforeEach, describe, expect, it } from 'vitest' 2 - 3 - describe('hooks should timeout', () => { 4 - beforeEach(async () => { 5 - await new Promise(resolve => setTimeout(resolve, 20)) 6 - }, 10) 7 - it('hello', () => { 8 - expect(true).toBe(true) 9 - }) 10 - })
-15
test/fails/fixtures/hooks-called.test.ts
··· 1 - import { afterAll, beforeAll, expect, test } from 'vitest' 2 - 3 - beforeAll(() => { 4 - // should both appear in snapshot 5 - throw new Error('before all') 6 - }) 7 - 8 - afterAll(() => { 9 - // should both appear in snapshot 10 - throw new Error('after all') 11 - }) 12 - 13 - test('1 = 1', () => { 14 - expect(1).toBe(1) 15 - })
-27
test/fails/fixtures/inline-snapshop-inside-each.test.ts
··· 1 - import { describe, expect, test } from 'vitest' 2 - 3 - test.each([1])('', () => { 4 - expect('').toMatchInlineSnapshot() 5 - }) 6 - 7 - describe.each([1])('', () => { 8 - test('', () => { 9 - expect('').toMatchInlineSnapshot() 10 - }) 11 - 12 - test.each([1])('', () => { 13 - expect('').toMatchInlineSnapshot() 14 - }) 15 - 16 - test('', () => { 17 - expect(() => { 18 - throw new Error('1') 19 - }).toThrowErrorMatchingInlineSnapshot() 20 - }) 21 - 22 - test.each([1])('', () => { 23 - expect(() => { 24 - throw new Error('1') 25 - }).toThrowErrorMatchingInlineSnapshot() 26 - }) 27 - })
-8
test/fails/fixtures/mock-import-proxy-module.test.ts
··· 1 - import { expect, test, vi } from './proxy-module' 2 - 3 - // This can be used only when imported directly from vitest 4 - vi.mock('vite') 5 - 6 - test('hi', () => { 7 - expect(1 + 1).toEqual(2) 8 - })
-15
test/fails/fixtures/nested-suite.test.ts
··· 1 - import { describe, expect, it } from 'vitest' 2 - 3 - describe('a', () => { 4 - describe('b', () => { 5 - describe('c', () => { 6 - describe('d', () => { 7 - describe('e', () => { 8 - it('very deep', () => { 9 - expect(true).toBe(false) 10 - }) 11 - }) 12 - }) 13 - }) 14 - }) 15 - })
-6
test/fails/fixtures/primitive-error.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test('primitive error thrown', () => { 4 - // eslint-disable-next-line no-throw-literal 5 - throw 42 6 - })
-1
test/fails/fixtures/proxy-module.ts
··· 1 - export * from 'vitest'
-11
test/fails/fixtures/snapshot-with-not.test.ts
··· 1 - import { expect, test } from "vitest" 2 - 3 - test.each([ 4 - 'toMatchSnapshot', 5 - 'toMatchFileSnapshot', 6 - 'toMatchInlineSnapshot', 7 - 'toThrowErrorMatchingSnapshot', 8 - 'toThrowErrorMatchingInlineSnapshot', 9 - ])('%s should fail with not', (api) => { 10 - (expect(0).not as any)[api]() 11 - })
-19
test/fails/fixtures/stall.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - // https://github.com/vitest-dev/vitest/issues/374 4 - // Passing `Error` instances across message channels could cause the test runner to stall, if 5 - // multiple tests fail. This suite is successful if it does not timeout, which is verified by the 6 - // test runner. 7 - 8 - test('test 1', () => { 9 - throw new TypeError('failure') 10 - }) 11 - test('test 2', () => { 12 - throw new TypeError('failure') 13 - }) 14 - test('test 3', () => { 15 - throw new TypeError('failure') 16 - }) 17 - test('test 4', () => { 18 - throw new TypeError('failure') 19 - })
-19
test/fails/fixtures/test-timeout.test.ts
··· 1 - import { suite, test } from 'vitest' 2 - 3 - test('hi', async () => { 4 - await new Promise(resolve => setTimeout(resolve, 1000)) 5 - }, 10) 6 - 7 - suite('suite timeout', () => { 8 - test('hi', async () => { 9 - await new Promise(resolve => setTimeout(resolve, 500)) 10 - }) 11 - }, { 12 - timeout: 100, 13 - }) 14 - 15 - suite('suite timeout simple input', () => { 16 - test('hi', async () => { 17 - await new Promise(resolve => setTimeout(resolve, 500)) 18 - }) 19 - }, 200)
-10
test/fails/fixtures/unhandled.test.ts
··· 1 - // @vitest-environment jsdom 2 - 3 - import { test } from 'vitest' 4 - 5 - test('unhandled exception', () => { 6 - addEventListener('custom', () => { 7 - throw new Error('some error') 8 - }) 9 - dispatchEvent(new Event('custom')) 10 - })
-12
test/fails/fixtures/vite.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - test: { 5 - pool: 'forks', 6 - poolOptions: { 7 - forks: { 8 - isolate: false, 9 - }, 10 - }, 11 - }, 12 - })
-48
test/fails/test/runner.test.ts
··· 1 - import { resolve } from 'pathe' 2 - import fg from 'fast-glob' 3 - import { expect, it } from 'vitest' 4 - 5 - import { runVitest } from '../../test-utils' 6 - 7 - const root = resolve(__dirname, '../fixtures') 8 - const files = await fg('**/*.test.ts', { cwd: root, dot: true }) 9 - 10 - it.each(files)('should fail %s', async (file) => { 11 - const { stderr } = await runVitest({ root }, [file]) 12 - 13 - expect(stderr).toBeTruthy() 14 - const msg = String(stderr) 15 - .split(/\n/g) 16 - .reverse() 17 - .filter(i => i.includes('Error: ') && !i.includes('Command failed') && !i.includes('stackStr') && !i.includes('at runTest')) 18 - .map(i => i.trim().replace(root, '<rootDir>'), 19 - ).join('\n') 20 - expect(msg).toMatchSnapshot(file) 21 - }, 30_000) 22 - 23 - it('should report coverage when "coverag.reportOnFailure: true" and tests fail', async () => { 24 - const { stdout } = await runVitest({ 25 - root, 26 - coverage: { 27 - enabled: true, 28 - provider: 'istanbul', 29 - reportOnFailure: true, 30 - reporter: ['text'], 31 - }, 32 - }, [files[0]]) 33 - 34 - expect(stdout).toMatch('Coverage report from istanbul') 35 - }) 36 - 37 - it('should not report coverage when "coverag.reportOnFailure" has default value and tests fail', async () => { 38 - const { stdout } = await runVitest({ 39 - root, 40 - coverage: { 41 - enabled: true, 42 - provider: 'istanbul', 43 - reporter: ['text'], 44 - }, 45 - }, [files[0]]) 46 - 47 - expect(stdout).not.toMatch('Coverage report from istanbul') 48 - })
-3
test/filters/fixtures-slash/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({})
-86
test/filters/test/testname-pattern.test.ts
··· 1 - import { join, resolve } from 'pathe' 2 - import { expect, test } from 'vitest' 3 - 4 - import { runVitest } from '../../test-utils' 5 - 6 - test.each([ 7 - { filter: 'example' }, 8 - { filter: '/example' }, 9 - { filter: resolve('./fixtures/test/example') }, 10 - ])('match by partial pattern $filter', async ({ filter }) => { 11 - const { stdout } = await runVitest({ root: './fixtures' }, [filter]) 12 - 13 - expect(stdout).toMatch('✓ test/example.test.ts > this will pass') 14 - expect(stdout).toMatch('Test Files 1 passed (1)') 15 - expect(stdout).not.toMatch('test/filters.test.ts') 16 - }) 17 - 18 - test('match by full test file name', async () => { 19 - const filename = resolve('./fixtures/test/example.test.ts') 20 - const { stdout } = await runVitest({ root: './fixtures' }, [filename]) 21 - 22 - expect(stdout).toMatch('✓ test/example.test.ts > this will pass') 23 - expect(stdout).toMatch('Test Files 1 passed (1)') 24 - expect(stdout).not.toMatch('test/filters.test.ts') 25 - }) 26 - 27 - test('match by pattern that also matches current working directory', async () => { 28 - const filter = 'filters' 29 - expect(process.cwd()).toMatch(filter) 30 - 31 - const { stdout } = await runVitest({ root: './fixtures' }, [filter]) 32 - 33 - expect(stdout).toMatch('✓ test/filters.test.ts > this will pass') 34 - expect(stdout).toMatch('Test Files 1 passed (1)') 35 - expect(stdout).not.toMatch('test/example.test.ts') 36 - }) 37 - 38 - test.each([ 39 - ['the parent of CWD', resolve(process.cwd(), '..')], 40 - ['the parent of CWD with slash', join(resolve(process.cwd(), '..'), '/')], 41 - ['the parent of a parent of CWD', resolve(process.cwd(), '..', '..')], 42 - ])('match by pattern that also matches %s: %s', async (_, filter) => { 43 - const { stdout } = await runVitest({ root: './fixtures' }, [filter]) 44 - 45 - expect(stdout).toMatch('✓ test/filters.test.ts > this will pass') 46 - expect(stdout).toMatch('× test/dont-run-this.test.ts > this will fail') 47 - expect(stdout).toMatch('✓ test/example.test.ts > this will pass') 48 - }) 49 - 50 - test.each([ 51 - { 52 - filter: 'basic', 53 - files: [ 54 - 'test/basic.test.ts', 55 - 'test/foo-basic/a.test.ts', 56 - 'test/basic/a.test.ts', 57 - 'test/basic-foo/a.test.ts', 58 - ], 59 - }, 60 - { 61 - filter: '/basic', 62 - files: [ 63 - 'test/basic.test.ts', 64 - 'test/basic/a.test.ts', 65 - 'test/basic-foo/a.test.ts', 66 - ], 67 - }, 68 - { 69 - filter: 'basic/', 70 - files: [ 71 - 'test/foo-basic/a.test.ts', 72 - 'test/basic/a.test.ts', 73 - ], 74 - }, 75 - { 76 - filter: '/basic/', 77 - files: [ 78 - 'test/basic/a.test.ts', 79 - ], 80 - }, 81 - ])('filter with slash $filter', async ({ filter, files }) => { 82 - const { stdout } = await runVitest({ root: './fixtures-slash' }, [filter]) 83 - expect(stdout).toMatch(`Test Files ${files.length} passed (${files.length})`) 84 - for (const file of files) 85 - expect(stdout).toMatch(`✓ ${file}`) 86 - })
-5
test/global-setup-fail/fixtures/example.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('example test', () => { 4 - expect(1 + 1).toBe(2) 5 - })
-15
test/global-setup-fail/fixtures/vitest.config.ts
··· 1 - import { resolve } from 'node:path' 2 - import { fileURLToPath } from 'node:url' 3 - import { defineConfig } from 'vite' 4 - 5 - const __filename = fileURLToPath(import.meta.url) 6 - const __dirname = resolve(__filename, '..') 7 - 8 - export default defineConfig({ 9 - test: { 10 - globals: true, 11 - globalSetup: [ 12 - resolve(__dirname, './globalSetup/error.js'), 13 - ], 14 - }, 15 - })
-17
test/global-setup-fail/test/runner.test.ts
··· 1 - import { resolve } from 'pathe' 2 - import { expect, it } from 'vitest' 3 - 4 - import { runVitest } from '../../test-utils' 5 - 6 - it('should fail', async () => { 7 - const root = resolve(__dirname, '../fixtures') 8 - const { stderr } = await runVitest({ root }) 9 - 10 - expect(stderr).toBeTruthy() 11 - const msg = String(stderr) 12 - .split(/\n/g) 13 - .reverse() 14 - .find(i => i.includes('Error: ')) 15 - ?.trim() 16 - expect(msg).toBe('Error: error') 17 - }, 50000)
+1 -1
test/global-setup/setupFiles/add-something-to-global.ts
··· 1 - import { afterAll, beforeAll } from 'vitest' 1 + import { afterAll, beforeAll, beforeEach } from 'vitest' 2 2 3 3 beforeAll(() => { 4 4 // @ts-expect-error type
+1 -1
test/global-setup/test/global-setup.test.ts
··· 1 - import { expect } from 'vitest' 1 + import { afterEach, beforeEach, expect, test } from 'vitest' 2 2 3 3 beforeEach(async () => { 4 4 await new Promise((resolve) => {
+1 -1
test/global-setup/test/setup-files.test.ts
··· 1 - import { expect } from 'vitest' 1 + import { expect, test } from 'vitest' 2 2 3 3 test('something has been added to global by setupFiles entry', async () => { 4 4 // @ts-expect-error type
-13
test/import-meta/src/add.ts
··· 1 - export function add(...args: number[]) { 2 - return args.reduce((a, b) => a + b, 0) 3 - } 4 - 5 - // in-source test suites 6 - if (import.meta.vitest) { 7 - const { it, expect } = import.meta.vitest 8 - it('add', () => { 9 - expect(add()).toBe(0) 10 - expect(add(1)).toBe(1) 11 - expect(add(1, 2, 3)).toBe(6) 12 - }) 13 - }
-23
test/import-meta/src/fibonacci.ts
··· 1 - import { add } from './add' 2 - 3 - export function fibonacci(n: number): number { 4 - if (n < 2) 5 - return n 6 - return add(fibonacci(n - 1), fibonacci(n - 2)) 7 - } 8 - 9 - if (import.meta.vitest) { 10 - const { it, expect } = import.meta.vitest 11 - it('fibonacci', () => { 12 - expect(fibonacci(0)).toBe(0) 13 - expect(fibonacci(1)).toBe(1) 14 - expect(fibonacci(2)).toBe(1) 15 - expect(fibonacci(3)).toBe(2) 16 - expect(fibonacci(4)).toBe(3) 17 - expect(fibonacci(5)).toBe(5) 18 - expect(fibonacci(6)).toBe(8) 19 - expect(fibonacci(7)).toBe(13) 20 - expect(fibonacci(8)).toBe(21) 21 - expect(fibonacci(9)).toMatchInlineSnapshot('34') 22 - }) 23 - }
-2
test/import-meta/src/index.ts
··· 1 - export * from './add' 2 - export * from './fibonacci'
-5
test/inspect/fixtures/math.test.ts
··· 1 - import { expect, test } from "vitest"; 2 - 3 - test("sum", () => { 4 - expect(1 + 1).toBe(2) 5 - })
-8
test/inspect/fixtures/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['./**.test.ts'], 6 - watch: false, 7 - }, 8 - })
-86
test/inspect/test/inspect.test.ts
··· 1 - import type { InspectorNotification } from 'node:inspector' 2 - import { expect, test } from 'vitest' 3 - import WebSocket from 'ws' 4 - 5 - import { isWindows } from '../../../packages/vite-node/src/utils' 6 - import { runVitestCli } from '../../test-utils' 7 - 8 - type Message = Partial<InspectorNotification<any>> 9 - 10 - test.skipIf(isWindows)('--inspect-brk stops at test file', async () => { 11 - const { vitest, waitForClose } = await runVitestCli('--root', 'fixtures', '--inspect-brk', '--no-file-parallelism') 12 - 13 - await vitest.waitForStderr('Debugger listening on ') 14 - const url = vitest.stderr.split('\n')[0].replace('Debugger listening on ', '') 15 - 16 - const { receive, send } = await createChannel(url) 17 - 18 - send({ method: 'Debugger.enable' }) 19 - send({ method: 'Runtime.enable' }) 20 - await receive('Runtime.executionContextCreated') 21 - 22 - const paused = receive('Debugger.paused') 23 - send({ method: 'Runtime.runIfWaitingForDebugger' }) 24 - 25 - const { params } = await paused 26 - const scriptId = params.callFrames[0].functionLocation.scriptId 27 - 28 - // Verify that debugger paused on test file 29 - const response = receive() 30 - send({ method: 'Debugger.getScriptSource', params: { scriptId } }) 31 - const { result } = await response as any 32 - 33 - expect(result.scriptSource).toContain('test("sum", () => {') 34 - expect(result.scriptSource).toContain('expect(1 + 1).toBe(2)') 35 - 36 - send({ method: 'Debugger.resume' }) 37 - 38 - await vitest.waitForStdout('Test Files 1 passed (1)') 39 - await waitForClose() 40 - }) 41 - 42 - async function createChannel(url: string) { 43 - const ws = new WebSocket(url) 44 - 45 - let id = 1 46 - let receiver = defer() 47 - 48 - ws.onerror = receiver.reject 49 - ws.onmessage = (message) => { 50 - const response = JSON.parse(message.data.toString()) 51 - receiver.resolve(response) 52 - } 53 - 54 - async function receive(filter?: string) { 55 - const message = await receiver.promise 56 - receiver = defer() 57 - 58 - if (filter && message.method !== filter) 59 - return receive(filter) 60 - 61 - return message 62 - } 63 - 64 - function send(message: Message) { 65 - ws.send(JSON.stringify({ ...message, id: id++ })) 66 - } 67 - 68 - await new Promise(r => ws.on('open', r)) 69 - 70 - return { receive, send } 71 - } 72 - 73 - function defer(): { 74 - promise: Promise<Message> 75 - resolve: (response: Message) => void 76 - reject: (error: unknown) => void 77 - } { 78 - const pr = {} as ReturnType<typeof defer> 79 - 80 - pr.promise = new Promise((resolve, reject) => { 81 - pr.resolve = resolve 82 - pr.reject = reject 83 - }) 84 - 85 - return pr 86 - }
-11
test/mixed-pools/test/child-specific.child_process.test.ts
··· 1 - import { isMainThread, threadId } from 'node:worker_threads' 2 - import { expect, test } from 'vitest' 3 - 4 - test('has access to child_process API', () => { 5 - expect(process.send).toBeDefined() 6 - }) 7 - 8 - test('doesn\'t have access to threads API', () => { 9 - expect(isMainThread).toBe(true) 10 - expect(threadId).toBe(0) 11 - })
-11
test/mixed-pools/test/threads-specific.threads.test.ts
··· 1 - import { isMainThread, threadId } from 'node:worker_threads' 2 - import { expect, test } from 'vitest' 3 - 4 - test('has access access to worker API', () => { 5 - expect(isMainThread).toBe(false) 6 - expect(threadId).toBeGreaterThan(0) 7 - }) 8 - 9 - test('doesn\'t have access access to child_process API', () => { 10 - expect(process.send).toBeUndefined() 11 - })
-5
test/network-imports/public/slash@3.0.0.js
··· 1 - /* eslint-disable */ 2 - // copied from https://esm.sh/v133/slash@3.0.0/es2022/slash.mjs to reduce network issues in CI 3 - 4 - /* esm.sh - esbuild bundle(slash@3.0.0) es2022 production */ 5 - var a=Object.create;var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),E=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!p.call(e,n)&&n!==r&&d(e,n,{get:()=>t[n],enumerable:!(i=m(t,n))||i.enumerable});return e},o=(e,t,r)=>(u(e,t,"default"),r&&u(r,t,"default")),c=(e,t,r)=>(r=e!=null?a(g(e)):{},u(t||!e||!e.__esModule?d(r,"default",{value:e,enumerable:!0}):r,e));var f=A((h,_)=>{"use strict";_.exports=e=>{let t=/^\\\\\?\\/.test(e),r=/[^\u0000-\u0080]+/.test(e);return t||r?e:e.replace(/\\/g,"/")}});var s={};E(s,{default:()=>P});var L=c(f());o(s,c(f()));var{default:l,...N}=L,P=l!==void 0?l:N;export{P as default};
-11
test/network-imports/test/basic.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - // @ts-expect-error network imports 4 - import slash from 'http://localhost:9602/slash@3.0.0.js' 5 - 6 - // test without local server 7 - // import slash from 'https://esm.sh/slash@3.0.0' 8 - 9 - test('network imports', () => { 10 - expect(slash('foo\\bar')).toBe('foo/bar') 11 - })
-1
test/path-resolution-target/dist/index.d.ts
··· 1 - export function sub(a: number, b: number): number
-3
test/path-resolution-target/dist/index.js
··· 1 - export function sub(a, b) { 2 - return a - b; 3 - }
-17
test/path-resolution/test/sister-package.test.ts
··· 1 - import { expect, it, vitest } from 'vitest' 2 - 3 - import { sub } from '@vitest/test-path-resolution-target' 4 - 5 - vitest.mock('@vitest/test-path-resolution-target') 6 - 7 - it('should be mocked', () => { 8 - expect(sub).toHaveProperty('mock') 9 - expect(sub(5, 3)).toBeUndefined() 10 - }) 11 - 12 - it('should import actual', async () => { 13 - const { sub } = await vitest.importActual<typeof import('@vitest/test-path-resolution-target')>('@vitest/test-path-resolution-target') 14 - 15 - expect(sub).not.toHaveProperty('mock') 16 - expect(sub(5, 3)).toBe(2) 17 - })
-20
test/public-api/fixtures/custom.spec.ts
··· 1 - import { afterAll, test } from 'vitest' 2 - 3 - declare module 'vitest' { 4 - interface TaskMeta { 5 - done?: boolean 6 - custom?: string 7 - } 8 - } 9 - 10 - afterAll((suite) => { 11 - suite.meta.done = true 12 - }) 13 - 14 - test('custom', ({ task }) => { 15 - task.meta.custom = 'some-custom-hanlder' 16 - }) 17 - 18 - test.each([1, 2])('custom %s', () => { 19 - // support locations 20 - })
-1
test/public-api/fixtures/vitest.config.ts
··· 1 - export default {}
-99
test/public-api/tests/runner.spec.ts
··· 1 - import { expect, it } from 'vitest' 2 - import type { File, TaskResultPack, UserConfig } from 'vitest' 3 - import { resolve } from 'pathe' 4 - import { runVitest } from '../../test-utils' 5 - 6 - it.each([ 7 - { name: 'threads are enabled', pool: 'threads' }, 8 - { name: 'threads are disabled', pool: 'forks' }, 9 - { 10 - name: 'running in the browser', 11 - browser: { 12 - enabled: true, 13 - provider: 'playwright', 14 - name: 'chromium', 15 - headless: true, 16 - }, 17 - }, 18 - ] as UserConfig[])('passes down metadata when $name', { timeout: 60_000, retry: 3 }, async (config) => { 19 - const taskUpdate: TaskResultPack[] = [] 20 - const finishedFiles: File[] = [] 21 - const collectedFiles: File[] = [] 22 - const { ctx, stdout, stderr } = await runVitest({ 23 - root: resolve(__dirname, '..', 'fixtures'), 24 - include: ['**/*.spec.ts'], 25 - reporters: [ 26 - 'verbose', 27 - { 28 - onTaskUpdate(packs) { 29 - taskUpdate.push(...packs.filter(i => i[1]?.state === 'pass')) 30 - }, 31 - onFinished(files) { 32 - finishedFiles.push(...files || []) 33 - }, 34 - onCollected(files) { 35 - collectedFiles.push(...files || []) 36 - }, 37 - }, 38 - ], 39 - includeTaskLocation: true, 40 - ...config, 41 - }) 42 - 43 - expect(stderr).toBe('') 44 - 45 - expect(stdout).toContain('custom.spec.ts > custom') 46 - 47 - const suiteMeta = { done: true } 48 - const testMeta = { custom: 'some-custom-hanlder' } 49 - 50 - expect(taskUpdate).toHaveLength(4) 51 - expect(finishedFiles).toHaveLength(1) 52 - 53 - const files = ctx?.state.getFiles() || [] 54 - expect(files).toHaveLength(1) 55 - 56 - expect(taskUpdate).toContainEqual( 57 - [ 58 - expect.any(String), 59 - expect.anything(), 60 - suiteMeta, 61 - ], 62 - ) 63 - 64 - expect(taskUpdate).toContainEqual( 65 - [ 66 - expect.any(String), 67 - expect.anything(), 68 - testMeta, 69 - ], 70 - ) 71 - 72 - expect(finishedFiles[0].meta).toEqual(suiteMeta) 73 - expect(finishedFiles[0].tasks[0].meta).toEqual(testMeta) 74 - 75 - expect(files[0].meta).toEqual(suiteMeta) 76 - expect(files[0].tasks[0].meta).toEqual(testMeta) 77 - 78 - expect(finishedFiles[0].tasks[0].location).toEqual({ 79 - line: 14, 80 - column: 1, 81 - }) 82 - expect(collectedFiles[0].tasks[0].location).toEqual({ 83 - line: 14, 84 - column: 1, 85 - }) 86 - expect(files[0].tasks[0].location).toEqual({ 87 - line: 14, 88 - column: 1, 89 - }) 90 - 91 - const eachTests = [1, 2] 92 - eachTests.forEach((name, index) => { 93 - expect(files[0].tasks[index + 1].name).toBe(`custom ${name}`) 94 - expect(files[0].tasks[index + 1].location).toEqual({ 95 - line: 18, 96 - column: 18, 97 - }) 98 - }) 99 - })
-1
test/resolve/pkg-browser/index.d.ts
··· 1 - export default ''
-8
test/resolve/pkg-browser/package.json
··· 1 - { 2 - "type": "module", 3 - "exports": { 4 - "types": "./index.d.ts", 5 - "browser": "./web.js", 6 - "node": "./ssr.js" 7 - } 8 - }
-1
test/resolve/pkg-browser/ssr.js
··· 1 - export default 'ssr'
-1
test/resolve/pkg-browser/web.js
··· 1 - export default 'web'
-1
test/resolve/pkg-node/index.d.ts
··· 1 - export default ''
-8
test/resolve/pkg-node/package.json
··· 1 - { 2 - "type": "module", 3 - "exports": { 4 - "types": "./index.d.ts", 5 - "node": "./ssr.js", 6 - "browser": "./web.js" 7 - } 8 - }
-1
test/resolve/pkg-node/ssr.js
··· 1 - export default 'ssr'
-1
test/resolve/pkg-node/web.js
··· 1 - export default 'web'
-11
test/resolve/test/ssr.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - import pkgNode from '../pkg-node' 3 - import pkgBrowser from '../pkg-browser' 4 - 5 - test('[ssr] resolves to ssr, when node is first in conditions', () => { 6 - expect(pkgNode).toBe('ssr') 7 - }) 8 - 9 - test('[ssr] resolves to ssr, when browser is first in conditions', () => { 10 - expect(pkgBrowser).toBe('ssr') 11 - })
-11
test/resolve/test/web.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - import pkgNode from '../pkg-node' 3 - import pkgBrowser from '../pkg-browser' 4 - 5 - test('[web] resolves to ssr, when node is first in conditions', () => { 6 - expect(pkgNode).toBe('ssr') 7 - }) 8 - 9 - test('[web] resolves to ssr, when browser is first in conditions', () => { 10 - expect(pkgBrowser).toBe('ssr') 11 - })
-3
test/restricted/src/math.js
··· 1 - export function multiply(a, b) { 2 - return a * b 3 - }
-7
test/restricted/tests/basic.spec.js
··· 1 - import { expect, it } from 'vitest' 2 - import { multiply } from '../src/math' 3 - 4 - it('2 x 2 = 4', () => { 5 - expect(multiply(2, 2)).toBe(4) 6 - expect(multiply(2, 2)).toBe(Math.sqrt(16)) 7 - })
-26
test/run-once/test/run-once.test.ts
··· 1 - import { expect, isFirstRun, it, runOnce } from 'vitest' 2 - 3 - let dummy = 0 4 - 5 - const one = runOnce(() => { 6 - dummy += 1 7 - return 1 8 - }) 9 - 10 - const two = await runOnce(async () => { 11 - dummy += 1 12 - return 2 13 - }) 14 - 15 - it('runOnce', async () => { 16 - expect(one).toBe(1) 17 - expect(two).toBe(2) 18 - 19 - // edit the file to trigger the hmr and dummy should be 0 20 - expect(dummy).toBe(2) 21 - }) 22 - 23 - it('isFirstRun', () => { 24 - // edit the file and this will fail 25 - expect(isFirstRun()).toBe(true) 26 - })
-16
test/run/allowed-exec-args-fixtures/allowed-exec-argv.test.ts
··· 1 - import { describe, expect, it } from 'vitest' 2 - 3 - describe('exec-args', async () => { 4 - it('should have the correct flags', () => { 5 - // flags that should go through 6 - expect(process.execArgv).toContain('--cpu-prof') 7 - expect(process.execArgv).toContain('--cpu-prof-name=cpu.prof') 8 - expect(process.execArgv).toContain('--heap-prof') 9 - expect(process.execArgv).toContain('--heap-prof-name=heap.prof') 10 - expect(process.execArgv).toContain('--diagnostic-dir=/tmp/vitest-diagnostics') 11 - 12 - // added via vitest 13 - expect(process.execArgv).toContain('--conditions') 14 - expect(process.execArgv).toContain('node') 15 - }) 16 - })
-3
test/run/allowed-exec-args-fixtures/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({})
-13
test/run/exec-args-fixtures/forks.test.ts
··· 1 - import { describe, expect, it } from 'vitest' 2 - 3 - describe('exec-args', async () => { 4 - it('should have the correct flags', () => { 5 - expect(process.execArgv).toContain('--hash-seed=1') 6 - expect(process.execArgv).toContain('--random-seed=1') 7 - expect(process.execArgv).toContain('--no-opt') 8 - 9 - // added via vitest 10 - expect(process.execArgv).toContain('--conditions') 11 - expect(process.execArgv).toContain('node') 12 - }) 13 - })
-11
test/run/exec-args-fixtures/threads.test.ts
··· 1 - import { describe, expect, it } from 'vitest' 2 - 3 - describe('exec-args', async () => { 4 - it('should have the correct flags', () => { 5 - expect(process.execArgv).toContain('--inspect-brk') 6 - 7 - // added via vitest 8 - expect(process.execArgv).toContain('--conditions') 9 - expect(process.execArgv).toContain('node') 10 - }) 11 - })
-15
test/run/exec-args-fixtures/vmThreads.test.ts
··· 1 - import { describe, expect, it } from 'vitest' 2 - 3 - describe('exec-args', async () => { 4 - it('should have the correct flags', () => { 5 - expect(process.execArgv).toContain('--inspect-brk') 6 - 7 - // added via vitest 8 - expect(process.execArgv).toContain('--experimental-import-meta-resolve') 9 - expect(process.execArgv).toContain('--experimental-vm-modules') 10 - expect(process.execArgv).toContain('--require') 11 - expect(process.execArgv).toContainEqual(expect.stringContaining('/packages/vitest/suppress-warnings.cjs')) 12 - expect(process.execArgv).toContain('--conditions') 13 - expect(process.execArgv).toContain('node') 14 - }) 15 - })
-7
test/run/fixtures/example.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - import { getHelloWorld } from './example' 4 - 5 - test('getHello', async () => { 6 - expect(getHelloWorld()).toBe('Hello world') 7 - })
-3
test/run/fixtures/example.ts
··· 1 - export function getHelloWorld() { 2 - return 'Hello world' 3 - }
-7
test/run/fixtures/math.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - import { sum } from './math' 4 - 5 - test('sum', () => { 6 - expect(sum(1, 2)).toBe(3) 7 - })
-3
test/run/fixtures/math.ts
··· 1 - export function sum(a: number, b: number) { 2 - return a + b 3 - }
-13
test/run/fixtures/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - // Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks 4 - process.stdin.isTTY = true 5 - process.stdin.setRawMode = () => process.stdin 6 - 7 - export default defineConfig({ 8 - test: { 9 - watch: false, 10 - reporters: 'verbose', 11 - teardownTimeout: 5_000, 12 - }, 13 - })
-12
test/run/no-exec-args-fixtures/no-exec-argv.test.ts
··· 1 - import { describe, expect, it } from 'vitest' 2 - 3 - describe('exec-args', async () => { 4 - it('should have the correct flags', () => { 5 - // flags should not be passed 6 - expect(process.execArgv).not.toContain('--title') 7 - 8 - // added via vitest 9 - expect(process.execArgv).toContain('--conditions') 10 - expect(process.execArgv).toContain('node') 11 - }) 12 - })
-3
test/run/no-exec-args-fixtures/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({})
-17
test/run/pool-custom-fixtures/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - name: 'custom-pool-test', 6 - pool: './pool/custom-pool.ts', 7 - poolOptions: { 8 - custom: { 9 - print: 'options are respected', 10 - array: [1, 2, 3], 11 - }, 12 - }, 13 - poolMatchGlobs: [ 14 - ['**/*.threads.spec.ts', 'threads'], 15 - ], 16 - }, 17 - })
-22
test/run/test/custom-pool.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - import { runVitest } from '../../test-utils' 3 - 4 - test('can run custom pools with Vitest', async () => { 5 - const vitest = await runVitest({ 6 - root: 'pool-custom-fixtures', 7 - reporters: ['basic'], 8 - }) 9 - 10 - expect(vitest.stderr).toMatchInlineSnapshot(` 11 - "[pool] printing: options are respected 12 - [pool] array option [ 1, 2, 3 ] 13 - [pool] running tests for custom-pool-test in /pool-custom-fixtures/tests/custom-not-run.spec.ts 14 - [pool] custom pool is closed! 15 - " 16 - `) 17 - 18 - expect(vitest.stdout).toContain('✓ |custom-pool-test| tests/custom-not-run.spec.ts') 19 - expect(vitest.stdout).toContain('✓ |custom-pool-test| tests/custom-run.threads.spec.ts') 20 - expect(vitest.stdout).toContain('Test Files 2 passed') 21 - expect(vitest.stdout).toContain('Tests 2 passed') 22 - })
-75
test/run/test/exec-args.test.ts
··· 1 - import { afterAll, beforeAll, expect, test } from 'vitest' 2 - import { execa } from 'execa' 3 - import { runVitest } from '../../test-utils' 4 - 5 - // VITEST_SEGFAULT_RETRY messes with the node flags, as can be seen in packages/vitest/src/node/cli-wrapper.ts 6 - // so here we remove it to make sure the tests are not affected by it 7 - const ORIGIN_VITEST_SEGFAULT_RETRY = process.env.VITEST_SEGFAULT_RETRY 8 - beforeAll(() => { 9 - delete process.env.VITEST_SEGFAULT_RETRY 10 - }) 11 - afterAll(() => { 12 - process.env.VITEST_SEGFAULT_RETRY = ORIGIN_VITEST_SEGFAULT_RETRY 13 - }) 14 - 15 - test.each([ 16 - { pool: 'forks', execArgv: ['--hash-seed=1', '--random-seed=1', '--no-opt'] }, 17 - { pool: 'threads', execArgv: ['--inspect-brk'] }, 18 - { pool: 'vmThreads', execArgv: ['--inspect-brk'] }, 19 - ] as const)('should pass execArgv to { pool: $pool } ', async ({ pool, execArgv }) => { 20 - const fileToTest = `exec-args-fixtures/${pool}.test.ts` 21 - 22 - const vitest = await runVitest({ 23 - include: [fileToTest], 24 - pool, 25 - poolOptions: { 26 - [pool]: { 27 - execArgv, 28 - }, 29 - }, 30 - }) 31 - 32 - expect(vitest.stdout).toContain(`✓ ${fileToTest}`) 33 - }) 34 - 35 - test('should not pass execArgv to workers when not specified in the config', async () => { 36 - const { stdout, stderr } = await execa('node', [ 37 - '--title', 38 - 'this-works-only-on-main-thread', 39 - '../node_modules/vitest/vitest.mjs', 40 - '--run', 41 - ], { 42 - cwd: `${process.cwd()}/no-exec-args-fixtures`, 43 - reject: false, 44 - env: { 45 - VITE_NODE_DEPS_MODULE_DIRECTORIES: '/node_modules/,/packages/', 46 - NO_COLOR: '1', 47 - }, 48 - }) 49 - 50 - expect(stderr).not.toContain('Error: Initiated Worker with invalid execArgv flags: --title') 51 - expect(stderr).not.toContain('ERR_WORKER_INVALID_EXEC_ARGV') 52 - expect(stdout).toContain('✓ no-exec-argv.test.ts') 53 - }) 54 - 55 - test('should let allowed args pass to workers', async () => { 56 - const { stdout, stderr } = await execa('node', [ 57 - '--cpu-prof', 58 - '--heap-prof', 59 - '--diagnostic-dir=/tmp/vitest-diagnostics', 60 - '--cpu-prof-name=cpu.prof', 61 - '--heap-prof-name=heap.prof', 62 - '../node_modules/vitest/vitest.mjs', 63 - '--run', 64 - ], { 65 - cwd: `${process.cwd()}/allowed-exec-args-fixtures`, 66 - reject: false, 67 - env: { 68 - VITE_NODE_DEPS_MODULE_DIRECTORIES: '/node_modules/,/packages/', 69 - NO_COLOR: '1', 70 - }, 71 - }) 72 - 73 - expect(stderr).toBe('') 74 - expect(stdout).toContain('✓ allowed-exec-argv.test.ts') 75 - })
-14
test/run/test/tty.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - import { runVitestCli } from '../../test-utils' 3 - 4 - test('run mode does not get stuck when TTY', async () => { 5 - const { vitest } = await runVitestCli('--root', 'fixtures') 6 - 7 - await vitest.waitForStdout('✓ example.test.ts') 8 - await vitest.waitForStdout('✓ math.test.ts') 9 - await vitest.waitForStdout('2 passed') 10 - 11 - // Regression #3642 12 - expect(vitest.stderr).not.toContain('close timed out') 13 - expect(vitest.stderr).toBe('') 14 - })
-4
test/setup/setupFiles/console-setup.ts
··· 1 - // eslint-disable-next-line no-console 2 - console.log('setup') 3 - 4 - console.error('setup')
test/setup/setupFiles/empty-setup.ts
-19
test/setup/tests/console-setup.test.ts
··· 1 - import { normalize } from 'node:path' 2 - import { describe, expect, test } from 'vitest' 3 - import { runVitest } from '../../test-utils' 4 - 5 - async function run() { 6 - return await runVitest({ 7 - include: ['tests/fixtures/console.test.ts'], 8 - setupFiles: ['setupFiles/console-setup.ts'], 9 - }) 10 - } 11 - 12 - describe('setup files console', () => { 13 - test('print stdout and stderr correctly', async () => { 14 - const { stdout, stderr } = await run() 15 - const filepath = normalize('setupFiles/console-setup.ts') 16 - expect(stdout).toContain(`stdout | ${filepath}`) 17 - expect(stderr).toContain(`stderr | ${filepath}`) 18 - }) 19 - })
-5
test/setup/tests/empty-setup.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - 3 - it('should success', async () => { 4 - expect(1 + 1).toBe(2) 5 - })
-33
test/setup/tests/setup-files.test.ts
··· 1 - import { promises as fs } from 'node:fs' 2 - import { afterEach, describe, expect, it } from 'vitest' 3 - 4 - import { runVitest } from '../../test-utils' 5 - 6 - async function run() { 7 - return await runVitest({ 8 - include: ['tests/empty-setup.test.ts'], 9 - setupFiles: ['setupFiles/empty-setup.ts'], 10 - changed: true, 11 - }) 12 - } 13 - 14 - describe('setup files with forceRerunTrigger', () => { 15 - const file = './setupFiles/empty-setup.ts' 16 - 17 - afterEach(async () => { 18 - await fs.writeFile(file, '', 'utf-8') 19 - }) 20 - 21 - // Note that this test will fail locally if you have uncommitted changes 22 - it.runIf(process.env.GITHUB_ACTIONS)('should run no tests if setup file is not changed', async () => { 23 - const { stdout } = await run() 24 - expect(stdout).toContain('No test files found, exiting with code 0') 25 - }, 60_000) 26 - 27 - it('should run the whole test suite if setup file is changed', async () => { 28 - const codes = 'export const a = 1' 29 - await fs.writeFile(file, codes, 'utf-8') 30 - const { stdout } = await run() 31 - expect(stdout).toContain('1 passed') 32 - }, 60_000) 33 - })
-3
test/shard/test/1.test.js
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('1', () => expect(1).toBe(1))
-3
test/shard/test/2.test.js
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('2', () => expect(1).toBe(1))
-3
test/shard/test/3.test.js
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('3', () => expect(1).toBe(1))
-11
test/single-thread/test/a.test.ts
··· 1 - import fs from 'node:fs' 2 - import { expect, it, vi } from 'vitest' 3 - import { timeout } from './timeout' 4 - 5 - // this file is running first, it should not affect file "b.test.ts" 6 - it('mock is mocked', () => { 7 - vi.spyOn(fs, 'readFileSync').mockReturnValue('mocked') 8 - expect(fs.readFileSync('')).toBe('mocked') 9 - }) 10 - 11 - it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout)))
-18
test/single-thread/test/b.test.ts
··· 1 - import fs from 'node:fs' 2 - import { fileURLToPath } from 'node:url' 3 - import { dirname, resolve } from 'pathe' 4 - import { expect, it } from 'vitest' 5 - import { timeout } from './timeout' 6 - 7 - // this file is running second, it should not be affected by mock in "a.test.ts" 8 - it('mock is mocked', () => { 9 - expect(fs.readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), './timeout.ts'), 'utf-8')).toMatchInlineSnapshot(` 10 - "export const timeout = 200 11 - export const mockedFn = function () { 12 - return 'original' 13 - } 14 - " 15 - `) 16 - }) 17 - 18 - it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout)))
-4
test/single-thread/test/c.test.ts
··· 1 - import { it } from 'vitest' 2 - import { timeout } from './timeout' 3 - 4 - it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout)))
-8
test/single-thread/test/d.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - import { timeout } from './timeout' 3 - 4 - it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout))) 5 - 6 - it('1', () => { 7 - expect(1).toEqual(1) 8 - })
-4
test/single-thread/test/timeout.ts
··· 1 - export const timeout = 200 2 - export const mockedFn = function () { 3 - return 'original' 4 - }
-10
test/snapshots/test/shapshots-concurrent-sync.test.ts
··· 1 - import { describe, it } from 'vitest' 2 - 3 - // from https://github.com/vitest-dev/vitest/issues/3361 4 - describe.concurrent('concurrent suite', () => { 5 - it('snapshot', ({ expect }) => { 6 - expect({ foo: 'bar' }).toMatchSnapshot() 7 - }) 8 - 9 - it('empty test') 10 - })
-15
test/snapshots/test/shapshots-concurrent.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - const data = [ 4 - 'one', 5 - 'two', 6 - 'three', 7 - 'four', 8 - ] 9 - 10 - data.forEach((i) => { 11 - test.concurrent(i, async ({ expect }) => { 12 - await new Promise(resolve => setTimeout(resolve, Math.random() * 100)) 13 - expect(i).toMatchSnapshot() 14 - }) 15 - })
-20
test/snapshots/test/shapshots-file.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - function objectToCSS(selector: string, obj: Record<string, string>) { 4 - const body = Object.entries(obj) 5 - .map(([key, value]) => ` ${key}: ${value};`) 6 - .join('\n') 7 - return `${selector} {\n${body}\n}` 8 - } 9 - 10 - describe('snapshots', () => { 11 - const files = import.meta.glob('./fixtures/**/input.json', { as: 'raw' }) 12 - 13 - for (const [path, file] of Object.entries(files)) { 14 - test(path, async () => { 15 - const entries = JSON.parse(await file()) as any[] 16 - expect(entries.map(i => objectToCSS(i[0], i[1])).join('\n')) 17 - .toMatchFileSnapshot(path.replace('input.json', 'output.css')) 18 - }) 19 - } 20 - })
-52
test/snapshots/test/shapshots.test.ts
··· 1 - import fs from 'node:fs/promises' 2 - import pathe from 'pathe' 3 - import { expect, test } from 'vitest' 4 - 5 - function println() { 6 - const message = ` 7 - export default function () { 8 - function Foo() { 9 - } 10 - 11 - return Foo; 12 - } 13 - ` 14 - return message 15 - } 16 - 17 - test('non default snapshot format', () => { 18 - expect({ foo: ['bar'] }).toMatchInlineSnapshot(` 19 - Object { 20 - "foo": Array [ 21 - "bar", 22 - ], 23 - } 24 - `) 25 - }) 26 - 27 - test('multiline strings ', () => { 28 - expect(println()).toMatchSnapshot() 29 - }) 30 - 31 - test('updateInlineSnapshot should not remove end whitespace', () => { 32 - // issue #922 33 - expect(` 34 - my string 35 - `).toMatchInlineSnapshot(` 36 - " 37 - my string 38 - " 39 - `) 40 - }) 41 - 42 - test('js snapshots generated correctly', async () => { 43 - const path = pathe.resolve(__dirname, '../test-update/snapshots-inline-js.test.js') 44 - const content = await fs.readFile(path, 'utf8') 45 - expect(content).toMatchSnapshot() 46 - }) 47 - 48 - test('concurrent snapshot update', async () => { 49 - const path = pathe.resolve(__dirname, '../test-update/inline-test-template-concurrent.test.js') 50 - const content = await fs.readFile(path, 'utf8') 51 - expect(content).toMatchSnapshot() 52 - })
-17
test/snapshots/test/snapshots-async.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - function resolve() { 4 - return Promise.resolve('foo') 5 - } 6 - function reject() { 7 - return Promise.reject(new Error('foo')) 8 - } 9 - 10 - test('resolved inline', async () => { 11 - await expect(resolve()).resolves.toMatchInlineSnapshot('"foo"') 12 - }) 13 - 14 - test('rejected inline', async () => { 15 - await expect(reject()).rejects.toMatchInlineSnapshot('[Error: foo]') 16 - await expect(reject()).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: foo]`) 17 - })
+44
test/snapshots/test/snapshots.test.ts
··· 1 + import fs from 'node:fs/promises' 2 + import { expect, test } from 'vitest' 3 + import pathe from 'pathe' 4 + 5 + import { editFile, runVitest } from '../../test-utils' 6 + 7 + test('non default snapshot format', () => { 8 + expect({ foo: ['bar'] }).toMatchInlineSnapshot(` 9 + Object { 10 + "foo": Array [ 11 + "bar", 12 + ], 13 + } 14 + `) 15 + }) 16 + 17 + test('js snapshots generated correctly', async () => { 18 + const path = pathe.resolve(__dirname, '../test-update/snapshots-inline-js.test.js') 19 + const content = await fs.readFile(path, 'utf8') 20 + expect(content).toMatchSnapshot() 21 + }) 22 + 23 + test('concurrent snapshot update', async () => { 24 + const path = pathe.resolve(__dirname, '../test-update/inline-test-template-concurrent.test.js') 25 + const content = await fs.readFile(path, 'utf8') 26 + expect(content).toMatchSnapshot() 27 + }) 28 + 29 + test('--update works for workspace project', async () => { 30 + // setup wrong snapshot value 31 + editFile( 32 + 'test/fixtures/workspace/packages/space/test/__snapshots__/basic.test.ts.snap', 33 + data => data.replace('`1`', '`2`'), 34 + ) 35 + 36 + // run with --update 37 + const { stdout, exitCode } = await runVitest({ 38 + update: true, 39 + root: 'test/fixtures/workspace', 40 + workspace: 'vitest.workspace.ts', 41 + }) 42 + expect.soft(stdout).include('Snapshots 1 updated') 43 + expect.soft(exitCode).toBe(0) 44 + })
-19
test/snapshots/test/workspace.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - import { editFile, runVitest } from '../../test-utils' 3 - 4 - test('--update works for workspace project', async () => { 5 - // setup wrong snapshot value 6 - editFile( 7 - 'test/fixtures/workspace/packages/space/test/__snapshots__/basic.test.ts.snap', 8 - data => data.replace('`1`', '`2`'), 9 - ) 10 - 11 - // run with --update 12 - const { stdout, exitCode } = await runVitest({ 13 - update: true, 14 - root: 'test/fixtures/workspace', 15 - workspace: 'vitest.workspace.ts', 16 - }) 17 - expect.soft(stdout).include('Snapshots 1 updated') 18 - expect.soft(exitCode).toBe(0) 19 - })
-9
test/stacktraces/fixtures/add-in-imba.test.imba
··· 1 - import {it, expect} from 'vitest' 2 - 3 - export def add(...args) 4 - return args.reduce((do(a, b) a + b), 0) 5 - 6 - it "add", do 7 - expect(add()).toBe 0 8 - expect(add(1)).toBe 3 9 - expect(add(1, 2, 3)).toBe 6
-9
test/stacktraces/fixtures/add-in-js.test.js
··· 1 - /* body */ 2 - import { expect, it } from 'vitest' 3 - import { add } from './utils' 4 - 5 - it('add', () => { 6 - expect(add()).toBe(100) 7 - expect(add(1)).toBe(1) 8 - return expect(add(1, 2, 3)).toBe(6) 9 - })
-15
test/stacktraces/fixtures/add.test.ts
··· 1 - /* body */ 2 - import { expect, it } from 'vitest' 3 - import { add } from './utils' 4 - 5 - interface Num { 6 - count: number 7 - } 8 - 9 - const a: Num = { count: 10 } 10 - 11 - it('add', () => { 12 - expect(add(a.count)).toBe(100) 13 - expect(add(1)).toBe(1) 14 - return expect(add(1, 2, 3)).toBe(6) 15 - })
-6
test/stacktraces/fixtures/error-in-deps.test.js
··· 1 - import { test } from 'vitest' 2 - import { add } from './foo' 3 - 4 - test('error in deps', () => { 5 - add() 6 - })
-21
test/stacktraces/fixtures/error-with-stack.test.js
··· 1 - import { test } from 'vitest' 2 - 3 - test('error in deps', () => { 4 - a() 5 - }) 6 - 7 - function a() { 8 - b() 9 - } 10 - 11 - function b() { 12 - c() 13 - } 14 - 15 - function c() { 16 - d() 17 - } 18 - 19 - function d() { 20 - throw new Error('Something truly horrible has happened!') 21 - }
-4
test/stacktraces/fixtures/foo.js
··· 1 - export function add() { 2 - // eslint-disable-next-line no-undef 3 - return bar() 4 - }
-4
test/stacktraces/fixtures/frame.spec.imba
··· 1 - describe "Test" do 2 - test("1+1") do 3 - expect(1+1).toBe 2 4 - ciyet.
-7
test/stacktraces/fixtures/mocked-global.test.js
··· 1 - /* eslint-disable no-undef */ 2 - 3 - vi.mock('./path') 4 - 5 - test('failed', () => { 6 - expect(1).toBe(2) 7 - })
-7
test/stacktraces/fixtures/mocked-imported.test.js
··· 1 - import { expect, test, vi } from 'vitest' 2 - 3 - vi.mock('./path') 4 - 5 - test('failed', () => { 6 - expect(1).toBe(2) 7 - })
-7
test/stacktraces/fixtures/mocked-imported.test.ts
··· 1 - import { expect, test, vi } from 'vitest' 2 - 3 - vi.mock('./path') 4 - 5 - test('failed', () => { 6 - expect(1).toBe(2) 7 - })
-18
test/stacktraces/fixtures/reset-modules.test.ts
··· 1 - import { assert, describe, expect, it, vi } from 'vitest' 2 - 3 - describe('suite name', () => { 4 - it('foo', () => { 5 - vi.resetModules() 6 - // a comment here 7 - // another comment 8 - // another comment 9 - // another comment 10 - // another comment 11 - // another comment 12 - // this will mess up the stacktrace lines 13 - expect(1 + 1).eq(2) 14 - expect(2 + 1).eq(3) 15 - assert.equal(Math.sqrt(4), 2) 16 - expect(Math.sqrt(4)).toBe(1) 17 - }) 18 - })
-5
test/stacktraces/fixtures/setup.js
··· 1 - import { expect, test, vi } from 'vitest' 2 - 3 - globalThis.vi = vi 4 - globalThis.test = test 5 - globalThis.expect = expect
-3
test/stacktraces/fixtures/utils.ts
··· 1 - export function add(...args: number[]) { 2 - return args.reduce((a, b) => a + b, 0) 3 - }
-49
test/stacktraces/fixtures/vite.config.ts
··· 1 - import { defineConfig } from 'vite' 2 - 3 - export default defineConfig({ 4 - plugins: [{ 5 - name: 'vite-plugin-imba', 6 - transform(code, id) { 7 - if (id.endsWith('frame.spec.imba')) { 8 - // eslint-disable-next-line no-throw-literal 9 - throw { 10 - name: 'imba-parser error', 11 - id, 12 - message: 'Unexpected \'CALL_END\'', 13 - code, 14 - frame: 15 - '4 | test("1+1") do\n5 | expect(1+1).toBe 2\n6 | frame.\n | ^\n7 |\n', 16 - loc: { 17 - line: 3, 18 - column: 11, 19 - file: id, 20 - }, 21 - } 22 - } 23 - if (id.endsWith('.imba')) { 24 - return { 25 - code: 26 - '\n/*body*/\nimport {it,expect} from \'vitest\';\n\nexport function add(...args){\n\t\n\treturn args.reduce(function(a,b) { return a + b; },0);\n};\n\nit("add",function() {\n\t\n\texpect(add()).toBe(0);\n\texpect(add(1)).toBe(3);\n\treturn expect(add(1,2,3)).toBe(6);\n});', 27 - map: { 28 - version: 3, 29 - file: 'add-in-imba.test.imba', 30 - names: [], 31 - sourceRoot: '', 32 - sources: ['add-in-imba.test.imba'], 33 - sourcesContent: [ 34 - 'import {it, expect} from \'vitest\'\n\nexport def add(...args)\n\treturn args.reduce((do(a, b) a + b), 0)\n\nit "add", do\n\texpect(add()).toBe 0\n\texpect(add(1)).toBe 3\n\texpect(add(1, 2, 3)).toBe 6\n', 35 - ], 36 - mappings: 37 - ';;AAAA,MAAM,EAAE,EAAE,CAAE,MAAM,OAAO,QAAQ;;AAEjC,MAAM,CAAC,QAAG,CAAC,GAAG,IAAI,IAAI,CAAC;;CACtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAE,QAAE,CAAC,CAAC,CAAE,CAAC,IAAE,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,IAAG,CAAC,CAAC;CAAA;;AAExC,EAAE,CAAC,KAAK,CAAE,QAAE,GAAA;;CACX,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;CACpB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;CACrB,OAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;CAAA,CAH1B;AAIF;', 38 - }, 39 - } 40 - } 41 - }, 42 - }], 43 - test: { 44 - isolate: false, 45 - pool: 'forks', 46 - include: ['**/*.{test,spec}.{imba,?(c|m)[jt]s?(x)}'], 47 - setupFiles: ['./setup.js'], 48 - }, 49 - })
-79
test/stacktraces/test/runner.test.ts
··· 1 - import { resolve } from 'pathe' 2 - import fg from 'fast-glob' 3 - import { describe, expect, it } from 'vitest' 4 - 5 - import { runVitest } from '../../test-utils' 6 - 7 - // To prevent the warnining coming up in snapshots 8 - process.setMaxListeners(20) 9 - 10 - describe('stacktraces should respect sourcemaps', async () => { 11 - const root = resolve(__dirname, '../fixtures') 12 - const files = await fg('*.test.*', { cwd: root }) 13 - 14 - for (const file of files) { 15 - it(file, async () => { 16 - const { stderr } = await runVitest({ root }, [file]) 17 - 18 - expect(stderr).toBeTruthy() 19 - const lines = String(stderr).split(/\n/g) 20 - const index = lines.findIndex(val => val.includes(`${file}:`)) 21 - const msg = lines.slice(index, index + 8).join('\n') 22 - expect(msg).toMatchSnapshot(file) 23 - }, 30000) 24 - } 25 - }) 26 - 27 - describe('stacktraces should pick error frame if present', async () => { 28 - const root = resolve(__dirname, '../fixtures') 29 - const files = ['frame.spec.imba'] 30 - 31 - for (const file of files) { 32 - it(file, async () => { 33 - const { stderr } = await runVitest({ root }, [file]) 34 - 35 - expect(stderr).toBeTruthy() 36 - const lines = String(stderr).split(/\n/g) 37 - const index = lines.findIndex(val => val.includes('FAIL')) 38 - const msg = lines.slice(index, index + 8).join('\n') 39 - expect(msg).toMatchSnapshot(file) 40 - }, 30000) 41 - } 42 - }) 43 - 44 - describe('stacktrace should print error frame source file correctly', async () => { 45 - const root = resolve(__dirname, '../fixtures') 46 - const testFile = resolve(root, './error-in-deps.test.js') 47 - 48 - it('error-in-deps', async () => { 49 - const { stderr } = await runVitest({ root }, [testFile]) 50 - 51 - // expect to print framestack of foo.js 52 - expect(stderr).toMatchSnapshot('error-in-deps') 53 - }, 30000) 54 - }) 55 - 56 - describe('stacktrace filtering', async () => { 57 - const root = resolve(__dirname, '../fixtures') 58 - const testFile = resolve(root, './error-with-stack.test.js') 59 - 60 - it('filters stacktraces', async () => { 61 - const { stderr } = await runVitest({ 62 - root, 63 - onStackTrace: (_error, { method }) => method !== 'b', 64 - }, [testFile]) 65 - 66 - expect(stderr).toMatchSnapshot('stacktrace-filtering') 67 - }, 30000) 68 - }) 69 - 70 - it('stacktrace in vmThreads', async () => { 71 - const root = resolve(__dirname, '../fixtures') 72 - const testFile = resolve(root, './error-with-stack.test.js') 73 - const { stderr } = await runVitest({ 74 - root, 75 - pool: 'vmThreads', 76 - }, [testFile]) 77 - 78 - expect(stderr).toMatchSnapshot() 79 - }, 3000)
-93
test/utils/test/display.spec.ts
··· 1 - import util from 'node:util' 2 - import { describe, expect, test } from 'vitest' 3 - import { format } from '@vitest/utils' 4 - 5 - describe('format', () => { 6 - const obj = {} as any 7 - obj.obj = obj 8 - 9 - test.each([ 10 - [''], 11 - ['test'], 12 - [{ obj: { nested: true }, value: 1 }], 13 - ['test %s', 'test'], 14 - ['test %s %s', 'test', 'test'], 15 - ['test %s %s', 'test', 'test', 'test'], 16 - ['%s', 100], 17 - ['%s', 100n], 18 - ['%s', -0], 19 - ['%s', null], 20 - ['%s', null, 'next'], 21 - ['%d', 100], 22 - ['%d', 100n], 23 - ['%d', null], 24 - ['%d', {}], 25 - ['%d', {}, 'next'], 26 - ['%i', 100], 27 - ['%i', 100n], 28 - ['%i', null], 29 - ['%i', {}], 30 - ['%i', {}, 'next'], 31 - ['%f', 100], 32 - ['%f', 100n], 33 - ['%f', null], 34 - ['%f', {}], 35 - ['%f', {}, 'next'], 36 - ['%o', 'string'], 37 - ['%o', 100], 38 - ['%o', 100n], 39 - ['%o', null], 40 - ['%o', {}], 41 - ['%o', {}, 'next'], 42 - ['%O', 'string'], 43 - ['%O', 100], 44 - ['%O', 100n], 45 - ['%O', null], 46 - ['%O', {}], 47 - ['%O', {}, 'next'], 48 - ['%c', 'css value'], 49 - ['%c', 'css value', 'some other value'], 50 - ['%c %f', 'css value', '100.00'], 51 - ['%j', 'string'], 52 - ['%j', 100], 53 - ['%j', null], 54 - ['%j', {}], 55 - ['%j', {}, 'next'], 56 - ['%j', { obj }], 57 - ['%j', { fn: () => {} }], 58 - ['%%', 'string'], 59 - ])('format(%s)', (formatString, ...args) => { 60 - expect(format(formatString, ...args), `failed ${formatString}`).toBe(util.format(formatString, ...args)) 61 - }) 62 - 63 - test('cannont serialize some values', () => { 64 - expect(() => format('%j', 100n)).toThrowErrorMatchingInlineSnapshot(`[TypeError: Do not know how to serialize a BigInt]`) 65 - }) 66 - 67 - test.each( 68 - [ 69 - { 70 - name: 'without format', 71 - args: [{ n: { a: { b: { c: { d: { e: '3' } } } } } }], 72 - result: '{ n: { a: { b: { c: { d: { e: \'3\' } } } } } }', 73 - }, 74 - { 75 - name: 'as an object', 76 - args: ['%o', {}, { n: { a: { b: { c: '3' } } } }], 77 - result: '{} { n: { a: { b: { c: \'3\' } } } }', 78 - }, 79 - { 80 - name: 'as a full object', 81 - args: ['%O', {}, { n: { a: { b: { c: '3' } } } }], 82 - result: '{} { n: { a: { b: { c: \'3\' } } } }', 83 - }, 84 - { 85 - name: 'as a json', 86 - args: ['%j', {}, { n: { a: { b: { c: '3' } } } }], 87 - result: '{} { n: { a: { b: { c: \'3\' } } } }', 88 - }, 89 - ], 90 - )('formats objects $name (loupe doesn\'t respect depth)', ({ args, result }) => { 91 - expect(format(...args)).toBe(result) 92 - }) 93 - })
-1
test/vite-config/src/index.html
··· 1 - Hello Vitest
-1
test/vite-config/src/src.ts
··· 1 - export const foo = 'foo'
-12
test/vite-node/test/external.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - // @ts-expect-error no ts 4 - import * as dep1 from '@vitest/test-dep1' 5 - 6 - // @ts-expect-error no ts 7 - import * as dep2 from '@vitest/test-dep2' 8 - 9 - test('no dual package hazard by externalizing esm deps by default', async () => { 10 - dep1.data.hello = 'world' 11 - expect(dep2.data.hello).toBe('world') 12 - })
-43
test/vm-threads/test/import-external-css-assets.test.js
··· 1 - // @vitest-environment jsdom 2 - 3 - import { describe, expect, test } from 'vitest' 4 - 5 - import '../src/external/css/empty.css' 6 - import '../src/external/css/processed.css' 7 - 8 - import processedModule from '../src/external/css/processed.module.css' 9 - 10 - import file1 from '../src/external/assets/file1.png' 11 - import file2 from '../src/external/assets/file2.txt' 12 - import file3 from '../src/external/assets/file3.svg' 13 - 14 - describe('import external css', () => { 15 - test('when importing empty.css, element doesn\'t change style', () => { 16 - const el = document.createElement('div') 17 - el.classList.add('test1') 18 - expect(el.classList.contains('test1')).toBe(true) 19 - expect(window.getComputedStyle(el).color).toBe('') 20 - }) 21 - 22 - test('when importing processed.css, element changes style', () => { 23 - const el = document.createElement('div') 24 - el.classList.add('test2') 25 - expect(el.classList.contains('test2')).toBe(true) 26 - expect(window.getComputedStyle(el).color).toBe('rgb(0, 128, 0)') 27 - }) 28 - 29 - test('when importing processed.module.css, element changes style', () => { 30 - const el = document.createElement('div') 31 - el.classList.add(processedModule.test3) 32 - expect(el.classList.contains(processedModule.test3)).toBe(true) 33 - expect(window.getComputedStyle(el).color).toBe('rgb(255, 255, 0)') 34 - }) 35 - }) 36 - 37 - describe('import external assets', () => { 38 - test('correctly imports assets as paths', () => { 39 - expect(file1).toBe('/src/external/assets/file1.png') 40 - expect(file2).toBe('/src/external/assets/file2.txt') 41 - expect(file3).toBe('/src/external/assets/file3.svg') 42 - }) 43 - })
-8
test/vm-threads/test/module.test.js
··· 1 - import { Module } from 'node:module' 2 - import { expect, it } from 'vitest' 3 - 4 - it('can create modules with incorrect filepath', () => { 5 - expect(() => new Module('name')).not.toThrow() 6 - // require will not work for these modules because native createRequire fails 7 - expect(() => new Module('some-other-name').require('node:url')).toThrow() 8 - })
-36
test/vm-threads/test/not-found.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - 3 - // @ts-expect-error untyped 4 - import * as notFound from '../src/external/not-found.js' 5 - 6 - it('path', async () => { 7 - await expect(() => notFound.importPath()).rejects.toMatchObject({ 8 - code: 'ERR_MODULE_NOT_FOUND', 9 - message: expect.stringMatching(/Cannot find module '.*?non-existing-path'/), 10 - }) 11 - }) 12 - 13 - // NodeJs's import.meta.resolve throws ERR_MODULE_NOT_FOUND error only this case. 14 - // For other cases, similar errors are fabricated by Vitest to mimic NodeJs's behavior. 15 - it('package', async () => { 16 - await expect(() => notFound.importPackage()).rejects.toMatchObject({ 17 - code: 'ERR_MODULE_NOT_FOUND', 18 - message: expect.stringContaining('Cannot find package \'@vitest/non-existing-package\''), 19 - }) 20 - }) 21 - 22 - it('builtin', async () => { 23 - await expect(() => notFound.importBuiltin()).rejects.toMatchObject({ 24 - code: 'ERR_MODULE_NOT_FOUND', 25 - message: 'Cannot find module \'node:non-existing-builtin\'', 26 - }) 27 - }) 28 - 29 - // this test fails before node 20.3.0 since it throws a different error (cf. https://github.com/nodejs/node/pull/47824) 30 - // > Only URLs with a scheme in: file and data are supported by the default ESM loader. Received protocol 'non-existing-namespace:' 31 - it('namespace', async () => { 32 - await expect(() => notFound.importNamespace()).rejects.toMatchObject({ 33 - code: 'ERR_MODULE_NOT_FOUND', 34 - message: 'Cannot find module \'non-existing-namespace:xyz\'', 35 - }) 36 - })
-32
test/vm-threads/test/require-cjs.test.js
··· 1 - import { createRequire } from 'node:module' 2 - import { describe, expect, test } from 'vitest' 3 - import { createFile, resolvePath } from '../../test-utils' 4 - 5 - const require = createRequire(import.meta.url) 6 - 7 - test('can require if package.json is null', () => { 8 - createFile(resolvePath(import.meta.url, '../src/external/package-null/package-null.json'), 'null') 9 - expect(() => require('../src/external/package-null/package-null.js')).not.toThrow() 10 - }) 11 - 12 - describe('validating nested defaults in isolation', async () => { 13 - const nestedDefaultExternalCjs = await import('../src/external/export-nested-default-cjs.js') 14 - const moduleDefaultCjs = await import('../src/external/export-default-cjs.js') 15 - 16 - test('nested default should be resolved', () => { 17 - expect(nestedDefaultExternalCjs).toHaveProperty('default') 18 - expect(nestedDefaultExternalCjs.default).not.toHaveProperty('default') 19 - expect(nestedDefaultExternalCjs.default.a).toBe('a') 20 - expect(nestedDefaultExternalCjs.default.b).toBe('b') 21 - expect(nestedDefaultExternalCjs.a).toBe('a') 22 - expect(nestedDefaultExternalCjs.b).toBe('b') 23 - }) 24 - 25 - test('externalized "module.exports" CJS module interops default', () => { 26 - expect(moduleDefaultCjs).toHaveProperty('default') 27 - expect(moduleDefaultCjs.default).toHaveProperty('a') 28 - expect(moduleDefaultCjs.default.a).toBe('a') 29 - expect(moduleDefaultCjs).toHaveProperty('a') 30 - expect(moduleDefaultCjs.a).toBe('a') 31 - }) 32 - })
test/wasm-modules/src/add.wasm

This is a binary file and will not be displayed.

-89
test/wasm-modules/test/basic.test.ts
··· 1 - import { readFileSync } from 'node:fs' 2 - import { resolve } from 'node:path' 3 - import { expect, test, vi } from 'vitest' 4 - 5 - // @ts-expect-error wasm is not typed 6 - import { add } from '../src/add.wasm' 7 - 8 - const wasmFileBuffer = readFileSync(resolve(__dirname, '../src/add.wasm')) 9 - 10 - test('supports native wasm imports', () => { 11 - expect(add(1, 2)).toBe(3) 12 - 13 - // because arguments are i32 (signed), fractional part is truncated 14 - expect(add(0.99, 1.01)).toBe(1) 15 - 16 - // because return value is i32 (signed), (2^31 - 1) + 1 overflows and becomes -2^31 17 - expect(add(2 ** 31 - 1, 1)).toBe(-(2 ** 31)) 18 - 19 - // invalid or missing arguments are treated as 0 20 - expect(add('hello', 'world')).toBe(0) 21 - expect(add()).toBe(0) 22 - expect(add(null)).toBe(0) 23 - expect(add({}, [])).toBe(0) 24 - 25 - // redundant arguments are silently ignored 26 - expect(add(1, 2, 3)).toBe(3) 27 - }) 28 - 29 - test('supports dynamic wasm imports', async () => { 30 - // @ts-expect-error wasm is not typed 31 - const { add: dynamicAdd } = await import('../src/add.wasm') 32 - expect(dynamicAdd(1, 2)).toBe(3) 33 - }) 34 - 35 - test('supports imports from "data:application/wasm" URI with base64 encoding', async () => { 36 - const importedWasmModule = await import( 37 - `data:application/wasm;base64,${wasmFileBuffer.toString('base64')}` 38 - ) 39 - expect(importedWasmModule.add(0, 42)).toBe(42) 40 - }) 41 - 42 - // TODO: error message is different on vm 43 - const isVm = process.execArgv.includes('--experimental-vm-modules') 44 - 45 - test('imports from "data:application/wasm" URI without explicit encoding fail', async () => { 46 - const error = await getError(() => import(`data:application/wasm,${wasmFileBuffer.toString('base64')}`)) 47 - if (isVm) 48 - expect(error).toMatchInlineSnapshot(`[Error: Missing data URI encoding]`) 49 - else 50 - expect(error).toMatchInlineSnapshot(`[CompileError: data:application/wasm,AGFzbQEAAAABBwFgAn9/AX8DAgEABwcBA2FkZAAACgkBBwAgACABags=: WebAssembly.compile(): expected magic word 00 61 73 6d, found 41 47 46 7a @+0]`) 51 - }) 52 - 53 - test('imports from "data:application/wasm" URI with invalid encoding fail', async () => { 54 - // @ts-expect-error import is not typed 55 - const error = await getError(() => import('data:application/wasm;charset=utf-8,oops')) 56 - if (isVm) 57 - expect(error).toMatchInlineSnapshot(`[Error: Invalid data URI encoding: charset=utf-8]`) 58 - else 59 - expect(error).toMatchInlineSnapshot(`[CompileError: data:application/wasm;charset=utf-8,oops: WebAssembly.compile(): expected magic word 00 61 73 6d, found 6f 6f 70 73 @+0]`) 60 - }) 61 - 62 - async function getError(f: () => unknown) { 63 - try { 64 - await f() 65 - } 66 - catch (e) { 67 - return e 68 - } 69 - expect.unreachable() 70 - } 71 - 72 - test('supports wasm/js cyclic import (old wasm-bindgen output)', async () => { 73 - globalThis.alert = vi.fn() 74 - 75 - // @ts-expect-error not typed 76 - const { greet } = await import('../src/wasm-bindgen/index.js') 77 - greet('World') 78 - 79 - expect(globalThis.alert).toHaveBeenCalledWith('Hello, World!') 80 - }) 81 - 82 - test('supports wasm-bindgen', async () => { 83 - globalThis.alert = vi.fn() 84 - 85 - const { greet } = await import('../src/wasm-bindgen-no-cyclic/index.js') 86 - greet('No Cyclic') 87 - 88 - expect(globalThis.alert).toHaveBeenCalledWith('Hello, No Cyclic!') 89 - })
+1 -1
test/watch/test/workspaces.test.ts
··· 8 8 const file = fileURLToPath(import.meta.url) 9 9 const dir = dirname(file) 10 10 const root = resolve(dir, '..', '..', 'workspaces') 11 - const config = resolve(root, 'vitest.config.ts') 11 + const config = resolve(root, 'vitest.config.watch.ts') 12 12 const cleanups: (() => void)[] = [] 13 13 14 14 const srcMathFile = resolve(root, 'src', 'math.ts')
-3
test/web-worker/src/eventListenerWorker.ts
··· 1 - self.addEventListener('message', (e) => { 2 - self.postMessage(`${e.data} world`) 3 - })
-3
test/web-worker/src/objectWorker.ts
··· 1 - self.onmessage = (e) => { 2 - self.postMessage(e.data) 3 - }
-3
test/web-worker/src/selfWorker.ts
··· 1 - import subSelf from './selfWorkerDep' 2 - 3 - self.postMessage(subSelf === self)
-1
test/web-worker/src/selfWorkerDep.ts
··· 1 - export default self
-10
test/web-worker/src/sharedWorker.ts
··· 1 - self.addEventListener('connect', (event) => { 2 - const e = event as MessageEvent 3 - const port = e.ports[0] 4 - 5 - port.onmessage = (e) => { 6 - port.postMessage(e.data) 7 - } 8 - 9 - port.start() 10 - })
-3
test/web-worker/src/worker.ts
··· 1 - self.onmessage = (e) => { 2 - self.postMessage(`${e.data} world`) 3 - }
-136
test/web-worker/test/clone.test.ts
··· 1 - import { version } from 'node:process' 2 - import { beforeEach, describe, expect, it, vi } from 'vitest' 3 - 4 - import MyWorker from '../src/objectWorker?worker' 5 - 6 - const major = Number(version.split('.')[0].slice(1)) 7 - 8 - describe.runIf(major >= 17)('when node supports structuredClone', () => { 9 - it('uses native structure clone', () => { 10 - expect.assertions(4) 11 - 12 - expect(structuredClone).toBeDefined() 13 - 14 - const worker = new MyWorker() 15 - const buffer = new ArrayBuffer(1) 16 - const obj = { hello: 'world', buffer } 17 - worker.postMessage(obj, [buffer]) 18 - 19 - return new Promise<void>((resolve, reject) => { 20 - worker.onmessage = (e) => { 21 - try { 22 - expect(e).toBeInstanceOf(MessageEvent) 23 - expect(e.data, 'doesn\'t keep reference').not.toBe(obj) 24 - expect(e.data, 'shape is equal').toEqual(obj) 25 - resolve() 26 - } 27 - catch (err) { 28 - reject(err) 29 - } 30 - finally { 31 - worker.terminate() 32 - } 33 - } 34 - }) 35 - }) 36 - 37 - it('throws error, if passing down unserializable data', () => { 38 - expect.assertions(4) 39 - 40 - expect(structuredClone).toBeDefined() 41 - 42 - const worker = new MyWorker() 43 - const obj = { hello: 'world', name() {} } 44 - worker.postMessage(obj) 45 - 46 - return new Promise<void>((resolve, reject) => { 47 - worker.onmessageerror = (e) => { 48 - try { 49 - expect(e.type).toBe('messageerror') 50 - expect(e).toBeInstanceOf(MessageEvent) 51 - expect(e.data.message).toContain( 52 - 'could not be cloned.', 53 - ) 54 - resolve() 55 - } 56 - catch (err) { 57 - reject(err) 58 - } 59 - } 60 - }) 61 - }) 62 - }) 63 - 64 - describe('when passing down custom clone', () => { 65 - const { warn } = console 66 - 67 - beforeEach(() => { 68 - console.warn = warn 69 - process.env.VITEST_WEB_WORKER_CLONE = undefined 70 - }) 71 - 72 - it('uses ponyfill clone', () => { 73 - expect.assertions(4) 74 - 75 - console.warn = vi.fn() 76 - process.env.VITEST_WEB_WORKER_CLONE = 'ponyfill' 77 - 78 - const worker = new MyWorker() 79 - const buffer = new ArrayBuffer(1) 80 - const obj = { hello: 'world' } 81 - worker.postMessage(obj, [buffer]) 82 - 83 - return new Promise<void>((resolve, reject) => { 84 - worker.onmessageerror = (e) => { 85 - reject(e.data) 86 - } 87 - worker.onmessage = (e) => { 88 - try { 89 - expect(e).toBeInstanceOf(MessageEvent) 90 - expect(e.data, 'doesn\'t keep reference').not.toBe(obj) 91 - expect(e.data, 'shape is not equal, don\'t transfer buffer').toEqual({ hello: 'world' }) 92 - expect(console.warn).toBeCalledWith(expect.stringContaining('[@vitest/web-worker] `structuredClone` is not supported in this')) 93 - resolve() 94 - } 95 - catch (err) { 96 - reject(err) 97 - } 98 - finally { 99 - worker.terminate() 100 - } 101 - } 102 - }) 103 - }) 104 - 105 - it('doesn\'t clone, if asked to', () => { 106 - expect.assertions(3) 107 - 108 - console.warn = vi.fn() 109 - process.env.VITEST_WEB_WORKER_CLONE = 'none' 110 - 111 - const worker = new MyWorker() 112 - const buffer = new ArrayBuffer(1) 113 - const obj = { hello: 'world', buffer } 114 - worker.postMessage(obj, [buffer]) 115 - 116 - return new Promise<void>((resolve, reject) => { 117 - worker.onmessageerror = (e) => { 118 - reject(e.data) 119 - } 120 - worker.onmessage = (e) => { 121 - try { 122 - expect(e).toBeInstanceOf(MessageEvent) 123 - expect(e.data, 'keeps reference').toBe(obj) 124 - expect(console.warn).not.toHaveBeenCalled() 125 - resolve() 126 - } 127 - catch (err) { 128 - reject(err) 129 - } 130 - finally { 131 - worker.terminate() 132 - } 133 - } 134 - }) 135 - }) 136 - })
-72
test/web-worker/test/init.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - 3 - import MyWorker from '../src/worker?worker' 4 - import MyEventListenerWorker from '../src/eventListenerWorker?worker' 5 - import MySelfWorker from '../src/selfWorker?worker' 6 - 7 - function sleep(time: number) { 8 - return new Promise(resolve => setTimeout(resolve, time)) 9 - } 10 - 11 - function testWorker(worker: Worker) { 12 - return new Promise<void>((resolve) => { 13 - worker.postMessage('hello') 14 - worker.onmessage = (e) => { 15 - expect(e.data).toBe('hello world') 16 - 17 - resolve() 18 - } 19 - }) 20 - } 21 - 22 - function testSelfWorker(worker: Worker) { 23 - return new Promise<boolean>((resolve) => { 24 - worker.onmessage = (e) => { 25 - resolve(e.data) 26 - } 27 - }) 28 - } 29 - 30 - it('worker exists', async () => { 31 - expect(Worker).toBeDefined() 32 - }) 33 - 34 - it('simple worker', async () => { 35 - expect.assertions(1) 36 - 37 - await testWorker(new MyWorker()) 38 - }) 39 - 40 - it('event listener worker', async () => { 41 - expect.assertions(1) 42 - 43 - await testWorker(new MyEventListenerWorker()) 44 - }) 45 - 46 - it('can test workers several times', async () => { 47 - expect.assertions(1) 48 - 49 - await testWorker(new MyWorker()) 50 - }) 51 - 52 - it('worker with url', async () => { 53 - expect.assertions(1) 54 - const url = import.meta.url 55 - 56 - await testWorker(new Worker(new URL('../src/worker.ts', url))) 57 - }) 58 - 59 - it('self injected into worker and its deps should be equal', async () => { 60 - expect.assertions(4) 61 - expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() 62 - // wait for clear worker mod cache 63 - await sleep(0) 64 - expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() 65 - 66 - await sleep(0) 67 - 68 - expect(await testSelfWorker(new Worker(new URL('../src/selfWorker.ts', import.meta.url)))).toBeTruthy() 69 - // wait for clear worker mod cache 70 - await sleep(0) 71 - expect(await testSelfWorker(new Worker(new URL('../src/selfWorker.ts', import.meta.url)))).toBeTruthy() 72 - })
-33
test/web-worker/test/jsdom.test.ts
··· 1 - // @vitest-environment jsdom 2 - 3 - import { expect, it } from 'vitest' 4 - 5 - it('worker with invalid url throws an error', async () => { 6 - const url = import.meta.url 7 - const worker = new Worker(new URL('../src/workerInvalid-path.ts', url)) 8 - const event = await new Promise<ErrorEvent>((resolve) => { 9 - worker.onerror = (e) => { 10 - resolve(e) 11 - } 12 - }) 13 - expect(event).toBeInstanceOf(ErrorEvent) 14 - // Error is in different context when running in VM. This is consistent with jest. 15 - if (!import.meta.env.VITEST_VM_POOL) 16 - expect(event.error).toBeInstanceOf(Error) 17 - expect(event.error.message).toContain('Failed to load') 18 - }) 19 - 20 - it('throws an error on invalid path', async () => { 21 - expect(SharedWorker).toBeDefined() 22 - const worker = new SharedWorker('./some-invalid-path') 23 - const event = await new Promise<ErrorEvent>((resolve) => { 24 - worker.onerror = (e) => { 25 - resolve(e) 26 - } 27 - }) 28 - expect(event).toBeInstanceOf(ErrorEvent) 29 - // Error is in different context when running in VM. This is consistent with jest. 30 - if (!import.meta.env.VITEST_VM_POOL) 31 - expect(event.error).toBeInstanceOf(Error) 32 - expect(event.error.message).toContain('Failed to load') 33 - })
-11
test/web-worker/test/postMessage.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - import MyWorker from '../src/worker?worker' 3 - 4 - it('throws syntax error if no arguments are provided', () => { 5 - const worker = new MyWorker() 6 - 7 - // @ts-expect-error requires at least one argument 8 - expect(() => worker.postMessage()).toThrowError(SyntaxError) 9 - expect(() => worker.postMessage(undefined)).not.toThrowError() 10 - expect(() => worker.postMessage(null)).not.toThrowError() 11 - })
-53
test/web-worker/test/sharedWorker.spec.ts
··· 1 - import { expect, it } from 'vitest' 2 - import MySharedWorker from '../src/sharedWorker?sharedworker' 3 - 4 - function sendEventMessage(worker: SharedWorker, msg: any) { 5 - worker.port.postMessage(msg) 6 - return new Promise<string>((resolve) => { 7 - worker.port.addEventListener('message', function onmessage(e) { 8 - worker.port.removeEventListener('message', onmessage) 9 - resolve(e.data as string) 10 - }) 11 - }) 12 - } 13 - 14 - function sendOnMessage(worker: SharedWorker, msg: any) { 15 - worker.port.postMessage(msg) 16 - return new Promise<string>((resolve) => { 17 - worker.port.onmessage = function onmessage(e) { 18 - worker.port.onmessage = null 19 - resolve(e.data as string) 20 - } 21 - }) 22 - } 23 - 24 - it('vite shared worker works', async () => { 25 - expect(MySharedWorker).toBeDefined() 26 - expect(SharedWorker).toBeDefined() 27 - const worker = new MySharedWorker() 28 - expect(worker).toBeInstanceOf(SharedWorker) 29 - 30 - await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') 31 - await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') 32 - }) 33 - 34 - it('shared worker with path works', async () => { 35 - expect(SharedWorker).toBeDefined() 36 - const worker = new SharedWorker(new URL('../src/sharedWorker.ts', import.meta.url)) 37 - expect(worker).toBeTruthy() 38 - 39 - await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') 40 - await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') 41 - }) 42 - 43 - it('doesn\'t trigger events, if closed', async () => { 44 - const worker = new MySharedWorker() 45 - worker.port.close() 46 - await new Promise((resolve) => { 47 - worker.port.addEventListener('message', () => { 48 - expect.fail('should not trigger message') 49 - }) 50 - worker.port.postMessage('event') 51 - setTimeout(resolve, 100) 52 - }) 53 - })
-19
test/ws-api/tests/server-url.test.ts
··· 1 - import { expect, it } from 'vitest' 2 - 3 - import { runVitest } from '../../test-utils' 4 - 5 - it('api server-url http', async () => { 6 - delete process.env.TEST_HTTPS 7 - const { stdout } = await runVitest({ root: 'fixtures/server-url', api: true }) 8 - expect(stdout).toContain('API started at http://localhost:51204/') 9 - expect(stdout).toContain('Test Files 1 passed') 10 - }) 11 - 12 - it('api server-url https', async () => { 13 - process.env.TEST_HTTPS = '1' 14 - const { stdout } = await runVitest({ root: 'fixtures/server-url', api: true }) 15 - expect(stdout).toContain('API started at https://localhost:51204/') 16 - expect(stdout).toContain('Test Files 1 passed') 17 - }) 18 - 19 - it.todo('api server-url fallback if resolvedUrls is null')
+7
packages/vitest/src/node/pool.ts
··· 1 1 import mm from 'micromatch' 2 2 import type { Awaitable } from '@vitest/utils' 3 3 import type { BuiltinPool, Pool } from '../types/pool-options' 4 + import { isWindows } from '../utils/env' 4 5 import type { Vitest } from './core' 5 6 import { createForksPool } from './pools/forks' 6 7 import { createThreadsPool } from './pools/threads' ··· 89 90 ...process.env, 90 91 ...ctx.config.env, 91 92 }, 93 + } 94 + 95 + // env are case-insensitive on Windows, but spawned processes don't support it 96 + if (isWindows) { 97 + for (const name in options.env) 98 + options.env[name.toUpperCase()] = options.env[name] 92 99 } 93 100 94 101 const customPools = new Map<string, ProcessPool>()
+1
packages/vitest/src/utils/env.ts
··· 1 1 export const isNode: boolean = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window 2 + export const isWindows = isNode && process.platform === 'win32' 2 3 export const isBrowser: boolean = typeof window !== 'undefined' 3 4 export { isCI, provider as stdProvider } from 'std-env'
+1 -2
packages/vitest/src/utils/index.ts
··· 1 1 import { relative } from 'pathe' 2 2 import { getWorkerState } from '../utils' 3 - import { isNode } from './env' 4 3 5 4 export * from './graph' 6 5 export * from './tasks' ··· 10 9 export * from './env' 11 10 export * from './modules' 12 11 export * from './serialization' 12 + export { isWindows } from './env' 13 13 14 - export const isWindows = isNode && process.platform === 'win32' 15 14 export function getRunMode() { 16 15 return getWorkerState().config.mode 17 16 }
-14
test/bail/fixtures/test/first.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('1 - first.test.ts - this should pass', async () => { 4 - await new Promise(resolve => setTimeout(resolve, 250)) 5 - expect(true).toBeTruthy() 6 - }) 7 - 8 - test('2 - first.test.ts - this should fail', () => { 9 - expect(false).toBeTruthy() 10 - }) 11 - 12 - test('3 - first.test.ts - this should be skipped', () => { 13 - expect(true).toBeTruthy() 14 - })
-17
test/bail/fixtures/test/second.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - // When using multi threads/forks the first test will start before failing.test.ts fails 4 - const isThreads = process.env.THREADS === 'true' 5 - 6 - test(`1 - second.test.ts - this should ${isThreads ? 'pass' : 'be skipped'}`, async () => { 7 - await new Promise(resolve => setTimeout(resolve, 1500)) 8 - expect(true).toBeTruthy() 9 - }) 10 - 11 - test('2 - second.test.ts - this should be skipped', () => { 12 - expect(true).toBeTruthy() 13 - }) 14 - 15 - test('3 - second.test.ts - this should be skipped', () => { 16 - expect(true).toBeTruthy() 17 - })
-7
test/changed/fixtures/related/not-related.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - import { B } from './src/sourceB' 3 - 4 - test('shouldn\'t run', () => { 5 - expect(B).toBe('B') 6 - expect.fail() 7 - })
-11
test/changed/fixtures/related/related.test.ts
··· 1 - import { access } from 'node:fs' 2 - import { sep } from 'pathe' 3 - import { expect, test } from 'vitest' 4 - import { A } from './src/sourceA' 5 - 6 - test('A equals A', () => { 7 - expect(A).toBe('A') 8 - expect(typeof sep).toBe('string') 9 - // doesn't throw 10 - expect(typeof access).toBe('function') 11 - })
-1
test/changed/fixtures/related/vitest.config.js
··· 1 - export default {}
-3
test/changed/fixtures/workspace/package.json
··· 1 - { 2 - "type": "commonjs" 3 - }
-1
test/changed/fixtures/workspace/vitest.config.mjs
··· 1 - export default {}
-3
test/changed/fixtures/workspace/vitest.workspace.js
··· 1 - export default [ 2 - "packages/*/vitest.config.js", 3 - ];
+7
test/cli/fixtures/custom-file-env/custom-file-env.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('custom env is defined', () => { 4 + expect(expect.getState().environment).toBe('custom') 5 + expect((globalThis as any).testEnvironment).toBe('custom') 6 + expect((globalThis as any).option).toBe('custom-option') 7 + })
+17
test/cli/fixtures/custom-pool/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({ 4 + test: { 5 + name: 'custom-pool-test', 6 + pool: './pool/custom-pool.ts', 7 + poolOptions: { 8 + custom: { 9 + print: 'options are respected', 10 + array: [1, 2, 3], 11 + }, 12 + }, 13 + poolMatchGlobs: [ 14 + ['**/*.threads.spec.ts', 'threads'], 15 + ], 16 + }, 17 + })
-7
test/cli/fixtures/exclude/math.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - import { add } from './math' 4 - 5 - test('should add two numbers correctly', () => { 6 - expect(add(1, 2)).toBe(3) 7 - })
-3
test/cli/fixtures/exclude/math.ts
··· 1 - export function add(a: number, b: number): number { 2 - return a + b 3 - }
-7
test/cli/fixtures/exclude/string.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - import { capitalize } from './string' 4 - 5 - test('should capitalize strings correctly', () => { 6 - expect(capitalize('i Love Vitest')).toBe('I love vitest') 7 - })
-3
test/cli/fixtures/exclude/string.ts
··· 1 - export function capitalize(str: string): string { 2 - return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase() 3 - }
-7
test/cli/fixtures/exclude/vitest.exclude.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - 3 - export default defineConfig({ 4 - test: { 5 - include: ['fixtures/exclude/*.test.ts'], 6 - }, 7 - })
+12
test/cli/fixtures/expect-soft/vite.config.ts
··· 1 + import { defineConfig } from 'vite' 2 + 3 + export default defineConfig({ 4 + test: { 5 + pool: 'forks', 6 + poolOptions: { 7 + forks: { 8 + isolate: false, 9 + }, 10 + }, 11 + }, 12 + })
+5
test/cli/fixtures/fails/each-timeout.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test.each([1])('test each timeout', async () => { 4 + await new Promise(resolve => setTimeout(resolve, 20)) 5 + }, 10)
test/cli/fixtures/fails/empty.test.ts
+3
test/cli/fixtures/fails/expect-soft.test.ts
··· 1 + import { expect } from 'vitest' 2 + 3 + expect.soft(1 + 1).toEqual(3)
+5
test/cli/fixtures/fails/expect-unreachable.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('', () => { 4 + expect.unreachable('hi') 5 + })
+5
test/cli/fixtures/fails/expect.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('hi', () => { 4 + expect(1 + 1).toEqual(3) 5 + })
+10
test/cli/fixtures/fails/hook-timeout.test.ts
··· 1 + import { beforeEach, describe, expect, it } from 'vitest' 2 + 3 + describe('hooks should timeout', () => { 4 + beforeEach(async () => { 5 + await new Promise(resolve => setTimeout(resolve, 20)) 6 + }, 10) 7 + it('hello', () => { 8 + expect(true).toBe(true) 9 + }) 10 + })
+15
test/cli/fixtures/fails/hooks-called.test.ts
··· 1 + import { afterAll, beforeAll, expect, test } from 'vitest' 2 + 3 + beforeAll(() => { 4 + // should both appear in snapshot 5 + throw new Error('before all') 6 + }) 7 + 8 + afterAll(() => { 9 + // should both appear in snapshot 10 + throw new Error('after all') 11 + }) 12 + 13 + test('1 = 1', () => { 14 + expect(1).toBe(1) 15 + })
+27
test/cli/fixtures/fails/inline-snapshop-inside-each.test.ts
··· 1 + import { describe, expect, test } from 'vitest' 2 + 3 + test.each([1])('', () => { 4 + expect('').toMatchInlineSnapshot() 5 + }) 6 + 7 + describe.each([1])('', () => { 8 + test('', () => { 9 + expect('').toMatchInlineSnapshot() 10 + }) 11 + 12 + test.each([1])('', () => { 13 + expect('').toMatchInlineSnapshot() 14 + }) 15 + 16 + test('', () => { 17 + expect(() => { 18 + throw new Error('1') 19 + }).toThrowErrorMatchingInlineSnapshot() 20 + }) 21 + 22 + test.each([1])('', () => { 23 + expect(() => { 24 + throw new Error('1') 25 + }).toThrowErrorMatchingInlineSnapshot() 26 + }) 27 + })
+8
test/cli/fixtures/fails/mock-import-proxy-module.test.ts
··· 1 + import { expect, test, vi } from './proxy-module' 2 + 3 + // This can be used only when imported directly from vitest 4 + vi.mock('vite') 5 + 6 + test('hi', () => { 7 + expect(1 + 1).toEqual(2) 8 + })
+15
test/cli/fixtures/fails/nested-suite.test.ts
··· 1 + import { describe, expect, it } from 'vitest' 2 + 3 + describe('a', () => { 4 + describe('b', () => { 5 + describe('c', () => { 6 + describe('d', () => { 7 + describe('e', () => { 8 + it('very deep', () => { 9 + expect(true).toBe(false) 10 + }) 11 + }) 12 + }) 13 + }) 14 + }) 15 + })
+6
test/cli/fixtures/fails/primitive-error.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test('primitive error thrown', () => { 4 + // eslint-disable-next-line no-throw-literal 5 + throw 42 6 + })
+1
test/cli/fixtures/fails/proxy-module.ts
··· 1 + export * from 'vitest'
+11
test/cli/fixtures/fails/snapshot-with-not.test.ts
··· 1 + import { expect, test } from "vitest" 2 + 3 + test.each([ 4 + 'toMatchSnapshot', 5 + 'toMatchFileSnapshot', 6 + 'toMatchInlineSnapshot', 7 + 'toThrowErrorMatchingSnapshot', 8 + 'toThrowErrorMatchingInlineSnapshot', 9 + ])('%s should fail with not', (api) => { 10 + (expect(0).not as any)[api]() 11 + })
+19
test/cli/fixtures/fails/stall.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + // https://github.com/vitest-dev/vitest/issues/374 4 + // Passing `Error` instances across message channels could cause the test runner to stall, if 5 + // multiple tests fail. This suite is successful if it does not timeout, which is verified by the 6 + // test runner. 7 + 8 + test('test 1', () => { 9 + throw new TypeError('failure') 10 + }) 11 + test('test 2', () => { 12 + throw new TypeError('failure') 13 + }) 14 + test('test 3', () => { 15 + throw new TypeError('failure') 16 + }) 17 + test('test 4', () => { 18 + throw new TypeError('failure') 19 + })
+19
test/cli/fixtures/fails/test-timeout.test.ts
··· 1 + import { suite, test } from 'vitest' 2 + 3 + test('hi', async () => { 4 + await new Promise(resolve => setTimeout(resolve, 1000)) 5 + }, 10) 6 + 7 + suite('suite timeout', () => { 8 + test('hi', async () => { 9 + await new Promise(resolve => setTimeout(resolve, 500)) 10 + }) 11 + }, { 12 + timeout: 100, 13 + }) 14 + 15 + suite('suite timeout simple input', () => { 16 + test('hi', async () => { 17 + await new Promise(resolve => setTimeout(resolve, 500)) 18 + }) 19 + }, 200)
+10
test/cli/fixtures/fails/unhandled.test.ts
··· 1 + // @vitest-environment jsdom 2 + 3 + import { test } from 'vitest' 4 + 5 + test('unhandled exception', () => { 6 + addEventListener('custom', () => { 7 + throw new Error('some error') 8 + }) 9 + dispatchEvent(new Event('custom')) 10 + })
+12
test/cli/fixtures/fails/vite.config.ts
··· 1 + import { defineConfig } from 'vite' 2 + 3 + export default defineConfig({ 4 + test: { 5 + pool: 'forks', 6 + poolOptions: { 7 + forks: { 8 + isolate: false, 9 + }, 10 + }, 11 + }, 12 + })
+5
test/cli/fixtures/global-setup-fail/example.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('example test', () => { 4 + expect(1 + 1).toBe(2) 5 + })
+15
test/cli/fixtures/global-setup-fail/vitest.config.ts
··· 1 + import { resolve } from 'node:path' 2 + import { fileURLToPath } from 'node:url' 3 + import { defineConfig } from 'vite' 4 + 5 + const __filename = fileURLToPath(import.meta.url) 6 + const __dirname = resolve(__filename, '..') 7 + 8 + export default defineConfig({ 9 + test: { 10 + globals: true, 11 + globalSetup: [ 12 + resolve(__dirname, './globalSetup/error.js'), 13 + ], 14 + }, 15 + })
+5
test/cli/fixtures/inspect/math.test.ts
··· 1 + import { expect, test } from "vitest"; 2 + 3 + test("sum", () => { 4 + expect(1 + 1).toBe(2) 5 + })
+8
test/cli/fixtures/inspect/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({ 4 + test: { 5 + include: ['./**.test.ts'], 6 + watch: false, 7 + }, 8 + })
+12
test/cli/fixtures/inspect/vitest.config.ts.timestamp-1713887058308-b154731a64b17.mjs
··· 1 + // fixtures/inspect/vitest.config.ts 2 + import { defineConfig } from "file:///Users/sheremet.mac/Projects/vitest/packages/vitest/dist/config.js"; 3 + var vitest_config_default = defineConfig({ 4 + test: { 5 + include: ["./**.test.ts"], 6 + watch: false 7 + } 8 + }); 9 + export { 10 + vitest_config_default as default 11 + }; 12 + //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiZml4dHVyZXMvaW5zcGVjdC92aXRlc3QuY29uZmlnLnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZGlybmFtZSA9IFwiL1VzZXJzL3NoZXJlbWV0Lm1hYy9Qcm9qZWN0cy92aXRlc3QvdGVzdC9jbGkvZml4dHVyZXMvaW5zcGVjdFwiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiL1VzZXJzL3NoZXJlbWV0Lm1hYy9Qcm9qZWN0cy92aXRlc3QvdGVzdC9jbGkvZml4dHVyZXMvaW5zcGVjdC92aXRlc3QuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9Vc2Vycy9zaGVyZW1ldC5tYWMvUHJvamVjdHMvdml0ZXN0L3Rlc3QvY2xpL2ZpeHR1cmVzL2luc3BlY3Qvdml0ZXN0LmNvbmZpZy50c1wiO2ltcG9ydCB7IGRlZmluZUNvbmZpZyB9IGZyb20gJ3ZpdGVzdC9jb25maWcnXG5cbmV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XG4gIHRlc3Q6IHtcbiAgICBpbmNsdWRlOiBbJy4vKioudGVzdC50cyddLFxuICAgIHdhdGNoOiBmYWxzZSxcbiAgfSxcbn0pXG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQTZXLFNBQVMsb0JBQW9CO0FBRTFZLElBQU8sd0JBQVEsYUFBYTtBQUFBLEVBQzFCLE1BQU07QUFBQSxJQUNKLFNBQVMsQ0FBQyxjQUFjO0FBQUEsSUFDeEIsT0FBTztBQUFBLEVBQ1Q7QUFDRixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo=
+11
test/cli/fixtures/network-imports/basic.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + // @ts-expect-error network imports 4 + import slash from 'http://localhost:9602/slash@3.0.0.js' 5 + 6 + // test without local server 7 + // import slash from 'https://esm.sh/slash@3.0.0' 8 + 9 + test('network imports', () => { 10 + expect(slash('foo\\bar')).toBe('foo/bar') 11 + })
-3
test/cli/fixtures/project/vitest.config.ts
··· 1 - import { defineConfig } from "vitest/config"; 2 - 3 - export default defineConfig({})
-3
test/cli/fixtures/project/vitest.workspace.ts
··· 1 - export default [ 2 - 'packages/*' 3 - ]
+20
test/cli/fixtures/public-api/custom.spec.ts
··· 1 + import { afterAll, test } from 'vitest' 2 + 3 + declare module 'vitest' { 4 + interface TaskMeta { 5 + done?: boolean 6 + custom?: string 7 + } 8 + } 9 + 10 + afterAll((suite) => { 11 + suite.meta.done = true 12 + }) 13 + 14 + test('custom', ({ task }) => { 15 + task.meta.custom = 'some-custom-hanlder' 16 + }) 17 + 18 + test.each([1, 2])('custom %s', () => { 19 + // support locations 20 + })
+1
test/cli/fixtures/public-api/vitest.config.ts
··· 1 + export default {}
+29
test/cli/fixtures/restricted-fs/vitest.config.ts
··· 1 + import { resolve } from 'pathe' 2 + import { defineConfig } from 'vite' 3 + 4 + export default defineConfig({ 5 + plugins: [ 6 + { 7 + // simulates restrictive FS 8 + name: 'restrict-fs', 9 + config() { 10 + return { 11 + server: { 12 + fs: { 13 + allow: [ 14 + resolve(__dirname, 'src'), 15 + ], 16 + }, 17 + }, 18 + } 19 + }, 20 + }, 21 + ], 22 + test: { 23 + environment: 'jsdom', 24 + include: ['tests/**/*.spec.{js,ts}'], 25 + setupFiles: [ 26 + './vitest.setup.js', 27 + ], 28 + }, 29 + })
+1
test/cli/fixtures/restricted-fs/vitest.setup.js
··· 1 + globalThis.SOME_TEST_VARIABLE = '3'
+4
test/cli/fixtures/setup-files/console-setup.ts
··· 1 + // eslint-disable-next-line no-console 2 + console.log('setup') 3 + 4 + console.error('setup')
test/cli/fixtures/setup-files/empty-setup.ts
+3
test/cli/fixtures/setup-files/empty.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test('empty', () => {})
+9
test/cli/fixtures/stacktraces/add-in-imba.test.imba
··· 1 + import {it, expect} from 'vitest' 2 + 3 + export def add(...args) 4 + return args.reduce((do(a, b) a + b), 0) 5 + 6 + it "add", do 7 + expect(add()).toBe 0 8 + expect(add(1)).toBe 3 9 + expect(add(1, 2, 3)).toBe 6
+9
test/cli/fixtures/stacktraces/add-in-js.test.js
··· 1 + /* body */ 2 + import { expect, it } from 'vitest' 3 + import { add } from './utils' 4 + 5 + it('add', () => { 6 + expect(add()).toBe(100) 7 + expect(add(1)).toBe(1) 8 + return expect(add(1, 2, 3)).toBe(6) 9 + })
+15
test/cli/fixtures/stacktraces/add.test.ts
··· 1 + /* body */ 2 + import { expect, it } from 'vitest' 3 + import { add } from './utils' 4 + 5 + interface Num { 6 + count: number 7 + } 8 + 9 + const a: Num = { count: 10 } 10 + 11 + it('add', () => { 12 + expect(add(a.count)).toBe(100) 13 + expect(add(1)).toBe(1) 14 + return expect(add(1, 2, 3)).toBe(6) 15 + })
+6
test/cli/fixtures/stacktraces/error-in-deps.test.js
··· 1 + import { test } from 'vitest' 2 + import { add } from './foo' 3 + 4 + test('error in deps', () => { 5 + add() 6 + })
+21
test/cli/fixtures/stacktraces/error-with-stack.test.js
··· 1 + import { test } from 'vitest' 2 + 3 + test('error in deps', () => { 4 + a() 5 + }) 6 + 7 + function a() { 8 + b() 9 + } 10 + 11 + function b() { 12 + c() 13 + } 14 + 15 + function c() { 16 + d() 17 + } 18 + 19 + function d() { 20 + throw new Error('Something truly horrible has happened!') 21 + }
+4
test/cli/fixtures/stacktraces/foo.js
··· 1 + export function add() { 2 + // eslint-disable-next-line no-undef 3 + return bar() 4 + }
+4
test/cli/fixtures/stacktraces/frame.spec.imba
··· 1 + describe "Test" do 2 + test("1+1") do 3 + expect(1+1).toBe 2 4 + ciyet.
+7
test/cli/fixtures/stacktraces/mocked-global.test.js
··· 1 + /* eslint-disable no-undef */ 2 + 3 + vi.mock('./path') 4 + 5 + test('failed', () => { 6 + expect(1).toBe(2) 7 + })
+7
test/cli/fixtures/stacktraces/mocked-imported.test.js
··· 1 + import { expect, test, vi } from 'vitest' 2 + 3 + vi.mock('./path') 4 + 5 + test('failed', () => { 6 + expect(1).toBe(2) 7 + })
+7
test/cli/fixtures/stacktraces/mocked-imported.test.ts
··· 1 + import { expect, test, vi } from 'vitest' 2 + 3 + vi.mock('./path') 4 + 5 + test('failed', () => { 6 + expect(1).toBe(2) 7 + })
+18
test/cli/fixtures/stacktraces/reset-modules.test.ts
··· 1 + import { assert, describe, expect, it, vi } from 'vitest' 2 + 3 + describe('suite name', () => { 4 + it('foo', () => { 5 + vi.resetModules() 6 + // a comment here 7 + // another comment 8 + // another comment 9 + // another comment 10 + // another comment 11 + // another comment 12 + // this will mess up the stacktrace lines 13 + expect(1 + 1).eq(2) 14 + expect(2 + 1).eq(3) 15 + assert.equal(Math.sqrt(4), 2) 16 + expect(Math.sqrt(4)).toBe(1) 17 + }) 18 + })
+5
test/cli/fixtures/stacktraces/setup.js
··· 1 + import { expect, test, vi } from 'vitest' 2 + 3 + globalThis.vi = vi 4 + globalThis.test = test 5 + globalThis.expect = expect
+3
test/cli/fixtures/stacktraces/utils.ts
··· 1 + export function add(...args: number[]) { 2 + return args.reduce((a, b) => a + b, 0) 3 + }
+49
test/cli/fixtures/stacktraces/vite.config.ts
··· 1 + import { defineConfig } from 'vite' 2 + 3 + export default defineConfig({ 4 + plugins: [{ 5 + name: 'vite-plugin-imba', 6 + transform(code, id) { 7 + if (id.endsWith('frame.spec.imba')) { 8 + // eslint-disable-next-line no-throw-literal 9 + throw { 10 + name: 'imba-parser error', 11 + id, 12 + message: 'Unexpected \'CALL_END\'', 13 + code, 14 + frame: 15 + '4 | test("1+1") do\n5 | expect(1+1).toBe 2\n6 | frame.\n | ^\n7 |\n', 16 + loc: { 17 + line: 3, 18 + column: 11, 19 + file: id, 20 + }, 21 + } 22 + } 23 + if (id.endsWith('.imba')) { 24 + return { 25 + code: 26 + '\n/*body*/\nimport {it,expect} from \'vitest\';\n\nexport function add(...args){\n\t\n\treturn args.reduce(function(a,b) { return a + b; },0);\n};\n\nit("add",function() {\n\t\n\texpect(add()).toBe(0);\n\texpect(add(1)).toBe(3);\n\treturn expect(add(1,2,3)).toBe(6);\n});', 27 + map: { 28 + version: 3, 29 + file: 'add-in-imba.test.imba', 30 + names: [], 31 + sourceRoot: '', 32 + sources: ['add-in-imba.test.imba'], 33 + sourcesContent: [ 34 + 'import {it, expect} from \'vitest\'\n\nexport def add(...args)\n\treturn args.reduce((do(a, b) a + b), 0)\n\nit "add", do\n\texpect(add()).toBe 0\n\texpect(add(1)).toBe 3\n\texpect(add(1, 2, 3)).toBe 6\n', 35 + ], 36 + mappings: 37 + ';;AAAA,MAAM,EAAE,EAAE,CAAE,MAAM,OAAO,QAAQ;;AAEjC,MAAM,CAAC,QAAG,CAAC,GAAG,IAAI,IAAI,CAAC;;CACtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAE,QAAE,CAAC,CAAC,CAAE,CAAC,IAAE,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,IAAG,CAAC,CAAC;CAAA;;AAExC,EAAE,CAAC,KAAK,CAAE,QAAE,GAAA;;CACX,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;CACpB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;CACrB,OAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;CAAA,CAH1B;AAIF;', 38 + }, 39 + } 40 + } 41 + }, 42 + }], 43 + test: { 44 + isolate: false, 45 + pool: 'forks', 46 + include: ['**/*.{test,spec}.{imba,?(c|m)[jt]s?(x)}'], 47 + setupFiles: ['./setup.js'], 48 + }, 49 + })
+7
test/cli/fixtures/tty/example.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { getHelloWorld } from './example' 4 + 5 + test('getHello', async () => { 6 + expect(getHelloWorld()).toBe('Hello world') 7 + })
+3
test/cli/fixtures/tty/example.ts
··· 1 + export function getHelloWorld() { 2 + return 'Hello world' 3 + }
+7
test/cli/fixtures/tty/math.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { sum } from './math' 4 + 5 + test('sum', () => { 6 + expect(sum(1, 2)).toBe(3) 7 + })
+3
test/cli/fixtures/tty/math.ts
··· 1 + export function sum(a: number, b: number) { 2 + return a + b 3 + }
+13
test/cli/fixtures/tty/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + // Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks 4 + process.stdin.isTTY = true 5 + process.stdin.setRawMode = () => process.stdin 6 + 7 + export default defineConfig({ 8 + test: { 9 + watch: false, 10 + reporters: 'verbose', 11 + teardownTimeout: 5_000, 12 + }, 13 + })
+43
test/cli/fixtures/vm-threads/import-external-css-assets.test.js
··· 1 + // @vitest-environment jsdom 2 + 3 + import { describe, expect, test } from 'vitest' 4 + 5 + import './src/external/css/empty.css' 6 + import './src/external/css/processed.css' 7 + 8 + import processedModule from './src/external/css/processed.module.css' 9 + 10 + import file1 from './src/external/assets/file1.png' 11 + import file2 from './src/external/assets/file2.txt' 12 + import file3 from './src/external/assets/file3.svg' 13 + 14 + describe('import external css', () => { 15 + test('when importing empty.css, element doesn\'t change style', () => { 16 + const el = document.createElement('div') 17 + el.classList.add('test1') 18 + expect(el.classList.contains('test1')).toBe(true) 19 + expect(window.getComputedStyle(el).color).toBe('') 20 + }) 21 + 22 + test('when importing processed.css, element changes style', () => { 23 + const el = document.createElement('div') 24 + el.classList.add('test2') 25 + expect(el.classList.contains('test2')).toBe(true) 26 + expect(window.getComputedStyle(el).color).toBe('rgb(0, 128, 0)') 27 + }) 28 + 29 + test('when importing processed.module.css, element changes style', () => { 30 + const el = document.createElement('div') 31 + el.classList.add(processedModule.test3) 32 + expect(el.classList.contains(processedModule.test3)).toBe(true) 33 + expect(window.getComputedStyle(el).color).toBe('rgb(255, 255, 0)') 34 + }) 35 + }) 36 + 37 + describe('import external assets', () => { 38 + test('correctly imports assets as paths', () => { 39 + expect(file1).toBe('/src/external/assets/file1.png') 40 + expect(file2).toBe('/src/external/assets/file2.txt') 41 + expect(file3).toBe('/src/external/assets/file3.svg') 42 + }) 43 + })
+8
test/cli/fixtures/vm-threads/module.test.js
··· 1 + import { Module } from 'node:module' 2 + import { expect, it } from 'vitest' 3 + 4 + it('can create modules with incorrect filepath', () => { 5 + expect(() => new Module('name')).not.toThrow() 6 + // require will not work for these modules because native createRequire fails 7 + expect(() => new Module('some-other-name').require('node:url')).toThrow() 8 + })
+36
test/cli/fixtures/vm-threads/not-found.test.ts
··· 1 + import { expect, it } from 'vitest' 2 + 3 + // @ts-expect-error untyped 4 + import * as notFound from './src/external/not-found.js' 5 + 6 + it('path', async () => { 7 + await expect(() => notFound.importPath()).rejects.toMatchObject({ 8 + code: 'ERR_MODULE_NOT_FOUND', 9 + message: expect.stringMatching(/Cannot find module '.*?non-existing-path'/), 10 + }) 11 + }) 12 + 13 + // NodeJs's import.meta.resolve throws ERR_MODULE_NOT_FOUND error only this case. 14 + // For other cases, similar errors are fabricated by Vitest to mimic NodeJs's behavior. 15 + it('package', async () => { 16 + await expect(() => notFound.importPackage()).rejects.toMatchObject({ 17 + code: 'ERR_MODULE_NOT_FOUND', 18 + message: expect.stringContaining('Cannot find package \'@vitest/non-existing-package\''), 19 + }) 20 + }) 21 + 22 + it('builtin', async () => { 23 + await expect(() => notFound.importBuiltin()).rejects.toMatchObject({ 24 + code: 'ERR_MODULE_NOT_FOUND', 25 + message: 'Cannot find module \'node:non-existing-builtin\'', 26 + }) 27 + }) 28 + 29 + // this test fails before node 20.3.0 since it throws a different error (cf. https://github.com/nodejs/node/pull/47824) 30 + // > Only URLs with a scheme in: file and data are supported by the default ESM loader. Received protocol 'non-existing-namespace:' 31 + it('namespace', async () => { 32 + await expect(() => notFound.importNamespace()).rejects.toMatchObject({ 33 + code: 'ERR_MODULE_NOT_FOUND', 34 + message: 'Cannot find module \'non-existing-namespace:xyz\'', 35 + }) 36 + })
+30
test/cli/fixtures/vm-threads/require-cjs.test.js
··· 1 + import { createRequire } from 'node:module' 2 + import { describe, expect, test } from 'vitest' 3 + 4 + const require = createRequire(import.meta.url) 5 + 6 + test('can require if package.json is null', () => { 7 + expect(() => require('./src/external/package-null/package-null.js')).not.toThrow() 8 + }) 9 + 10 + describe('validating nested defaults in isolation', async () => { 11 + const nestedDefaultExternalCjs = await import('./src/external/export-nested-default-cjs.js') 12 + const moduleDefaultCjs = await import('./src/external/export-default-cjs.js') 13 + 14 + test('nested default should be resolved', () => { 15 + expect(nestedDefaultExternalCjs).toHaveProperty('default') 16 + expect(nestedDefaultExternalCjs.default).not.toHaveProperty('default') 17 + expect(nestedDefaultExternalCjs.default.a).toBe('a') 18 + expect(nestedDefaultExternalCjs.default.b).toBe('b') 19 + expect(nestedDefaultExternalCjs.a).toBe('a') 20 + expect(nestedDefaultExternalCjs.b).toBe('b') 21 + }) 22 + 23 + test('externalized "module.exports" CJS module interops default', () => { 24 + expect(moduleDefaultCjs).toHaveProperty('default') 25 + expect(moduleDefaultCjs.default).toHaveProperty('a') 26 + expect(moduleDefaultCjs.default.a).toBe('a') 27 + expect(moduleDefaultCjs).toHaveProperty('a') 28 + expect(moduleDefaultCjs.a).toBe('a') 29 + }) 30 + })
+15
test/cli/fixtures/vm-threads/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({ 4 + test: { 5 + pool: 'vmThreads', 6 + css: { 7 + include: [/processed/], 8 + }, 9 + server: { 10 + deps: { 11 + external: [/src\/external/], 12 + }, 13 + }, 14 + }, 15 + })
+5
test/cli/fixtures/ws-server-url/basic.test.ts
··· 1 + import { expect, test } from "vitest"; 2 + 3 + test("basic", () => { 4 + expect(1).toBe(1); 5 + })
+11
test/cli/fixtures/ws-server-url/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + import basicSsl from '@vitejs/plugin-basic-ssl' 3 + 4 + // test https by 5 + // TEST_HTTPS=1 pnpm test --root fixtures/server-url --api 6 + 7 + export default defineConfig({ 8 + plugins: [ 9 + !!process.env.TEST_HTTPS && basicSsl(), 10 + ], 11 + })
+82
test/cli/test/__snapshots__/fails.test.ts.snap
··· 1 + // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 + 3 + exports[`should fail .dot-folder/dot-test.test.ts > .dot-folder/dot-test.test.ts 1`] = `"AssertionError: expected true to be false // Object.is equality"`; 4 + 5 + exports[`should fail each-timeout.test.ts > each-timeout.test.ts 1`] = `"Error: Test timed out in 10ms."`; 6 + 7 + exports[`should fail empty.test.ts > empty.test.ts 1`] = `"Error: No test suite found in file <rootDir>/empty.test.ts"`; 8 + 9 + exports[`should fail expect.test.ts > expect.test.ts 1`] = `"AssertionError: expected 2 to deeply equal 3"`; 10 + 11 + exports[`should fail expect-soft.test.ts > expect-soft.test.ts 1`] = `"Error: expect.soft() can only be used inside a test"`; 12 + 13 + exports[`should fail expect-unreachable.test.ts > expect-unreachable.test.ts 1`] = `"AssertionError: expected "hi" not to be reached"`; 14 + 15 + exports[`should fail hook-timeout.test.ts > hook-timeout.test.ts 1`] = `"Error: Hook timed out in 10ms."`; 16 + 17 + exports[`should fail hooks-called.test.ts > hooks-called.test.ts 1`] = ` 18 + "Error: after all 19 + Error: before all" 20 + `; 21 + 22 + exports[`should fail inline-snapshop-inside-each.test.ts > inline-snapshop-inside-each.test.ts 1`] = ` 23 + "Error: InlineSnapshot cannot be used inside of test.each or describe.each 24 + Error: InlineSnapshot cannot be used inside of test.each or describe.each 25 + Error: InlineSnapshot cannot be used inside of test.each or describe.each 26 + Error: InlineSnapshot cannot be used inside of test.each or describe.each 27 + Error: InlineSnapshot cannot be used inside of test.each or describe.each" 28 + `; 29 + 30 + exports[`should fail mock-import-proxy-module.test.ts > mock-import-proxy-module.test.ts 1`] = `"Error: There are some problems in resolving the mocks API."`; 31 + 32 + exports[`should fail nested-suite.test.ts > nested-suite.test.ts 1`] = `"AssertionError: expected true to be false // Object.is equality"`; 33 + 34 + exports[`should fail primitive-error.test.ts > primitive-error.test.ts 1`] = `"Unknown Error: 42"`; 35 + 36 + exports[`should fail snapshot-with-not.test.ts > snapshot-with-not.test.ts 1`] = ` 37 + "Error: toThrowErrorMatchingInlineSnapshot cannot be used with "not" 38 + Error: toThrowErrorMatchingSnapshot cannot be used with "not" 39 + Error: toMatchInlineSnapshot cannot be used with "not" 40 + Error: toMatchFileSnapshot cannot be used with "not" 41 + Error: toMatchSnapshot cannot be used with "not"" 42 + `; 43 + 44 + exports[`should fail stall.test.ts > stall.test.ts 1`] = ` 45 + "TypeError: failure 46 + TypeError: failure 47 + TypeError: failure 48 + TypeError: failure" 49 + `; 50 + 51 + exports[`should fail test-extend/circular-dependency.test.ts > test-extend/circular-dependency.test.ts 1`] = `"Error: Circular fixture dependency detected: a <- b <- a"`; 52 + 53 + exports[`should fail test-extend/fixture-error.test.ts > test-extend/fixture-error.test.ts 1`] = ` 54 + "Error: Error fixture teardown 55 + Error: Test timed out in 20ms. 56 + Error: Error thrown in test fixture 57 + Error: Error thrown in afterEach fixture 58 + Error: Error thrown in beforeEach fixture" 59 + `; 60 + 61 + exports[`should fail test-extend/fixture-rest-params.test.ts > test-extend/fixture-rest-params.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "...rest"."`; 62 + 63 + exports[`should fail test-extend/fixture-rest-props.test.ts > test-extend/fixture-rest-props.test.ts 1`] = `"Error: Rest parameters are not supported in fixtures, received "...rest"."`; 64 + 65 + exports[`should fail test-extend/fixture-without-destructuring.test.ts > test-extend/fixture-without-destructuring.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "context"."`; 66 + 67 + exports[`should fail test-extend/test-rest-params.test.ts > test-extend/test-rest-params.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "...rest"."`; 68 + 69 + exports[`should fail test-extend/test-rest-props.test.ts > test-extend/test-rest-props.test.ts 1`] = `"Error: Rest parameters are not supported in fixtures, received "...rest"."`; 70 + 71 + exports[`should fail test-extend/test-without-destructuring.test.ts > test-extend/test-without-destructuring.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "context"."`; 72 + 73 + exports[`should fail test-timeout.test.ts > test-timeout.test.ts 1`] = ` 74 + "Error: Test timed out in 200ms. 75 + Error: Test timed out in 100ms. 76 + Error: Test timed out in 10ms." 77 + `; 78 + 79 + exports[`should fail unhandled.test.ts > unhandled.test.ts 1`] = ` 80 + "Error: some error 81 + Error: Uncaught [Error: some error]" 82 + `;
+170
test/cli/test/__snapshots__/stacktraces.test.ts.snap
··· 1 + // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 + 3 + exports[`stacktrace filtering > filters stacktraces > stacktrace-filtering 1`] = ` 4 + "⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ 5 + 6 + FAIL error-with-stack.test.js > error in deps 7 + Error: Something truly horrible has happened! 8 + ❯ d error-with-stack.test.js:20:9 9 + 18| 10 + 19| function d() { 11 + 20| throw new Error('Something truly horrible has happened!') 12 + | ^ 13 + 21| } 14 + 22| 15 + ❯ c error-with-stack.test.js:16:3 16 + ❯ a error-with-stack.test.js:8:3 17 + ❯ error-with-stack.test.js:4:3 18 + 19 + ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 20 + 21 + " 22 + `; 23 + 24 + exports[`stacktrace in vmThreads 1`] = ` 25 + "⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ 26 + 27 + FAIL error-with-stack.test.js > error in deps 28 + Error: Something truly horrible has happened! 29 + ❯ d error-with-stack.test.js:20:9 30 + 18| 31 + 19| function d() { 32 + 20| throw new Error('Something truly horrible has happened!') 33 + | ^ 34 + 21| } 35 + 22| 36 + ❯ c error-with-stack.test.js:16:3 37 + ❯ b error-with-stack.test.js:12:3 38 + ❯ a error-with-stack.test.js:8:3 39 + ❯ error-with-stack.test.js:4:3 40 + 41 + ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 42 + 43 + " 44 + `; 45 + 46 + exports[`stacktrace should print error frame source file correctly > error-in-deps > error-in-deps 1`] = ` 47 + "⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ 48 + 49 + FAIL error-in-deps.test.js > error in deps 50 + ReferenceError: bar is not defined 51 + ❯ Module.add foo.js:3:3 52 + 1| export function add() { 53 + 2| // eslint-disable-next-line no-undef 54 + 3| return bar() 55 + | ^ 56 + 4| } 57 + 5| 58 + ❯ error-in-deps.test.js:5:3 59 + 60 + ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 61 + 62 + " 63 + `; 64 + 65 + exports[`stacktraces should pick error frame if present > frame.spec.imba > frame.spec.imba 1`] = ` 66 + " FAIL frame.spec.imba [ frame.spec.imba ] 67 + imba-parser error: Unexpected 'CALL_END' 68 + 4 | test("1+1") do 69 + 5 | expect(1+1).toBe 2 70 + 6 | frame. 71 + | ^ 72 + 7 | 73 + " 74 + `; 75 + 76 + exports[`stacktraces should respect sourcemaps > add.test.ts > add.test.ts 1`] = ` 77 + " ❯ add.test.ts:12:24 78 + 10| 79 + 11| it('add', () => { 80 + 12| expect(add(a.count)).toBe(100) 81 + | ^ 82 + 13| expect(add(1)).toBe(1) 83 + 14| return expect(add(1, 2, 3)).toBe(6) 84 + " 85 + `; 86 + 87 + exports[`stacktraces should respect sourcemaps > add-in-imba.test.imba > add-in-imba.test.imba 1`] = ` 88 + " ❯ add-in-imba.test.imba:8:17 89 + 6| it "add", do 90 + 7| expect(add()).toBe 0 91 + 8| expect(add(1)).toBe 3 92 + | ^ 93 + 9| expect(add(1, 2, 3)).toBe 6 94 + 10| 95 + " 96 + `; 97 + 98 + exports[`stacktraces should respect sourcemaps > add-in-js.test.js > add-in-js.test.js 1`] = ` 99 + " ❯ add-in-js.test.js:6:17 100 + 4| 101 + 5| it('add', () => { 102 + 6| expect(add()).toBe(100) 103 + | ^ 104 + 7| expect(add(1)).toBe(1) 105 + 8| return expect(add(1, 2, 3)).toBe(6) 106 + " 107 + `; 108 + 109 + exports[`stacktraces should respect sourcemaps > error-in-deps.test.js > error-in-deps.test.js 1`] = ` 110 + " ❯ error-in-deps.test.js:5:3 111 + 112 + ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 113 + 114 + " 115 + `; 116 + 117 + exports[`stacktraces should respect sourcemaps > error-with-stack.test.js > error-with-stack.test.js 1`] = ` 118 + " ❯ d error-with-stack.test.js:20:9 119 + 18| 120 + 19| function d() { 121 + 20| throw new Error('Something truly horrible has happened!') 122 + | ^ 123 + 21| } 124 + 22| 125 + ❯ c error-with-stack.test.js:16:3" 126 + `; 127 + 128 + exports[`stacktraces should respect sourcemaps > mocked-global.test.js > mocked-global.test.js 1`] = ` 129 + " ❯ mocked-global.test.js:6:13 130 + 4| 131 + 5| test('failed', () => { 132 + 6| expect(1).toBe(2) 133 + | ^ 134 + 7| }) 135 + 8| 136 + " 137 + `; 138 + 139 + exports[`stacktraces should respect sourcemaps > mocked-imported.test.js > mocked-imported.test.js 1`] = ` 140 + " ❯ mocked-imported.test.js:6:13 141 + 4| 142 + 5| test('failed', () => { 143 + 6| expect(1).toBe(2) 144 + | ^ 145 + 7| }) 146 + 8| 147 + " 148 + `; 149 + 150 + exports[`stacktraces should respect sourcemaps > mocked-imported.test.ts > mocked-imported.test.ts 1`] = ` 151 + " ❯ mocked-imported.test.ts:6:13 152 + 4| 153 + 5| test('failed', () => { 154 + 6| expect(1).toBe(2) 155 + | ^ 156 + 7| }) 157 + 8| 158 + " 159 + `; 160 + 161 + exports[`stacktraces should respect sourcemaps > reset-modules.test.ts > reset-modules.test.ts 1`] = ` 162 + " ❯ reset-modules.test.ts:16:26 163 + 14| expect(2 + 1).eq(3) 164 + 15| assert.equal(Math.sqrt(4), 2) 165 + 16| expect(Math.sqrt(4)).toBe(1) 166 + | ^ 167 + 17| }) 168 + 18| }) 169 + " 170 + `;
+14
test/config/fixtures/allowed-exec-args-fixtures/allowed-exec-argv.test.ts
··· 1 + import { describe, expect, it } from 'vitest' 2 + 3 + describe('exec-args', async () => { 4 + it('should have the correct flags', () => { 5 + // flags that should go through 6 + expect(process.execArgv).toContain('--heap-prof') 7 + expect(process.execArgv).toContain('--heap-prof-name=heap.prof') 8 + expect(process.execArgv).toContain('--diagnostic-dir=/tmp/vitest-diagnostics') 9 + 10 + // added via vitest 11 + expect(process.execArgv).toContain('--conditions') 12 + expect(process.execArgv).toContain('node') 13 + }) 14 + })
+3
test/config/fixtures/allowed-exec-args-fixtures/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({})
+35
test/config/fixtures/bail/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + import type { WorkspaceSpec } from 'vitest/node' 3 + 4 + class TestNameSequencer { 5 + async sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]> { 6 + return [...files].sort(([, filenameA], [, filenameB]) => { 7 + if (filenameA > filenameB) 8 + return 1 9 + 10 + if (filenameA < filenameB) 11 + return -1 12 + 13 + return 0 14 + }) 15 + } 16 + 17 + public async shard(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]> { 18 + return files 19 + } 20 + } 21 + 22 + export default defineConfig({ 23 + test: { 24 + reporters: 'verbose', 25 + cache: false, 26 + watch: false, 27 + sequence: { 28 + sequencer: TestNameSequencer, 29 + }, 30 + browser: { 31 + headless: true, 32 + name: 'chrome', 33 + }, 34 + }, 35 + })
+4
test/config/fixtures/css/App.css
··· 1 + .main { 2 + display: flex; 3 + width: 100px; 4 + }
+7
test/config/fixtures/css/App.module.css
··· 1 + .main { 2 + display: flex; 3 + } 4 + 5 + .module { 6 + width: 100px; 7 + }
+13
test/config/fixtures/css/utils.ts
··· 1 + import { afterEach, beforeEach } from 'vitest' 2 + 3 + function removeStyles() { 4 + document.head.querySelectorAll('style').forEach(style => style.remove()) 5 + } 6 + export function useRemoveStyles() { 7 + beforeEach(() => removeStyles()) 8 + afterEach(() => removeStyles()) 9 + 10 + return { 11 + removeStyles, 12 + } 13 + }
+7
test/config/fixtures/exclude/math.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { add } from './math' 4 + 5 + test('should add two numbers correctly', () => { 6 + expect(add(1, 2)).toBe(3) 7 + })
+3
test/config/fixtures/exclude/math.ts
··· 1 + export function add(a: number, b: number): number { 2 + return a + b 3 + }
+7
test/config/fixtures/exclude/string.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + import { capitalize } from './string' 4 + 5 + test('should capitalize strings correctly', () => { 6 + expect(capitalize('i Love Vitest')).toBe('I love vitest') 7 + })
+3
test/config/fixtures/exclude/string.ts
··· 1 + export function capitalize(str: string): string { 2 + return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase() 3 + }
+7
test/config/fixtures/exclude/vitest.exclude.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({ 4 + test: { 5 + include: ['fixtures/exclude/*.test.ts'], 6 + }, 7 + })
+13
test/config/fixtures/exec-args-fixtures/forks.test.ts
··· 1 + import { describe, expect, it } from 'vitest' 2 + 3 + describe('exec-args', async () => { 4 + it('should have the correct flags', () => { 5 + expect(process.execArgv).toContain('--hash-seed=1') 6 + expect(process.execArgv).toContain('--random-seed=1') 7 + expect(process.execArgv).toContain('--no-opt') 8 + 9 + // added via vitest 10 + expect(process.execArgv).toContain('--conditions') 11 + expect(process.execArgv).toContain('node') 12 + }) 13 + })
+11
test/config/fixtures/exec-args-fixtures/threads.test.ts
··· 1 + import { describe, expect, it } from 'vitest' 2 + 3 + describe('exec-args', async () => { 4 + it('should have the correct flags', () => { 5 + expect(process.execArgv).toContain('--inspect-brk') 6 + 7 + // added via vitest 8 + expect(process.execArgv).toContain('--conditions') 9 + expect(process.execArgv).toContain('node') 10 + }) 11 + })
+15
test/config/fixtures/exec-args-fixtures/vmThreads.test.ts
··· 1 + import { describe, expect, it } from 'vitest' 2 + 3 + describe('exec-args', async () => { 4 + it('should have the correct flags', () => { 5 + expect(process.execArgv).toContain('--inspect-brk') 6 + 7 + // added via vitest 8 + expect(process.execArgv).toContain('--experimental-import-meta-resolve') 9 + expect(process.execArgv).toContain('--experimental-vm-modules') 10 + expect(process.execArgv).toContain('--require') 11 + expect(process.execArgv).toContainEqual(expect.stringContaining('/packages/vitest/suppress-warnings.cjs')) 12 + expect(process.execArgv).toContain('--conditions') 13 + expect(process.execArgv).toContain('node') 14 + }) 15 + })
+3
test/config/fixtures/filters-slash/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({})
+5
test/config/fixtures/mixed-environments/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({ 4 + test: {}, 5 + })
+21
test/config/fixtures/mixed-environments/vitest.workspace.ts
··· 1 + import { resolve } from 'node:path' 2 + import { fileURLToPath } from 'node:url' 3 + import { defineWorkspace } from 'vitest/config' 4 + 5 + const __filename = fileURLToPath(import.meta.url) 6 + const __dirname = resolve(__filename, '..') 7 + 8 + export default defineWorkspace([ 9 + { 10 + test: { 11 + name: 'Project #1', 12 + root: resolve(__dirname, './project'), 13 + }, 14 + }, 15 + { 16 + test: { 17 + name: 'Project #2', 18 + root: resolve(__dirname, './project'), 19 + }, 20 + }, 21 + ])
+12
test/config/fixtures/no-exec-args-fixtures/no-exec-argv.test.ts
··· 1 + import { describe, expect, it } from 'vitest' 2 + 3 + describe('exec-args', async () => { 4 + it('should have the correct flags', () => { 5 + // flags should not be passed 6 + expect(process.execArgv).not.toContain('--title') 7 + 8 + // added via vitest 9 + expect(process.execArgv).toContain('--conditions') 10 + expect(process.execArgv).toContain('node') 11 + }) 12 + })
+3
test/config/fixtures/no-exec-args-fixtures/vitest.config.ts
··· 1 + import { defineConfig } from 'vitest/config' 2 + 3 + export default defineConfig({})
test/config/fixtures/pass-empty-files/empty.test.ts
+3
test/config/fixtures/project/vitest.config.ts
··· 1 + import { defineConfig } from "vitest/config"; 2 + 3 + export default defineConfig({})
+3
test/config/fixtures/project/vitest.workspace.ts
··· 1 + export default [ 2 + 'packages/*' 3 + ]
+1
test/config/fixtures/shard/vitest.config.js
··· 1 + export default {}
+7
test/config/fixtures/test/vitest.config.js
··· 1 + export default { 2 + test: { 3 + coverage: { 4 + reporter: [], 5 + }, 6 + } 7 + }
+5
test/core/deps/dep1/package.json
··· 1 + { 2 + "name": "@vitest/test-dep1", 3 + "type": "module", 4 + "exports": "./esm/index.js" 5 + }
+1
test/core/deps/dep2/index.js
··· 1 + export { data } from '@vitest/test-dep1'
+8
test/core/deps/dep2/package.json
··· 1 + { 2 + "name": "@vitest/test-dep2", 3 + "type": "module", 4 + "exports": "./index.js", 5 + "dependencies": { 6 + "@vitest/test-dep1": "file:../dep1" 7 + } 8 + }
+3
test/core/src/cjs/default-function.d.ts
··· 1 + declare function format(): string 2 + 3 + export default format
+8
test/core/src/cjs/default-function.js
··· 1 + 'use strict' 2 + 3 + function format() { 4 + return '' 5 + } 6 + 7 + module.exports = format 8 + module.exports.default = format
+7
test/core/src/cjs/prototype-cjs.js
··· 1 + exports.test = () => { 2 + // eslint-disable-next-line no-prototype-builtins 3 + return exports.hasOwnProperty('test') 4 + } 5 + exports.getPrototype = () => { 6 + return Object.getPrototypeOf(exports) 7 + }
+13
test/core/src/in-source/add.ts
··· 1 + export function add(...args: number[]) { 2 + return args.reduce((a, b) => a + b, 0) 3 + } 4 + 5 + // in-source test suites 6 + if (import.meta.vitest) { 7 + const { it, expect } = import.meta.vitest 8 + it('add', () => { 9 + expect(add()).toBe(0) 10 + expect(add(1)).toBe(1) 11 + expect(add(1, 2, 3)).toBe(6) 12 + }) 13 + }
+23
test/core/src/in-source/fibonacci.ts
··· 1 + import { add } from './add' 2 + 3 + export function fibonacci(n: number): number { 4 + if (n < 2) 5 + return n 6 + return add(fibonacci(n - 1), fibonacci(n - 2)) 7 + } 8 + 9 + if (import.meta.vitest) { 10 + const { it, expect } = import.meta.vitest 11 + it('fibonacci', () => { 12 + expect(fibonacci(0)).toBe(0) 13 + expect(fibonacci(1)).toBe(1) 14 + expect(fibonacci(2)).toBe(1) 15 + expect(fibonacci(3)).toBe(2) 16 + expect(fibonacci(4)).toBe(3) 17 + expect(fibonacci(5)).toBe(5) 18 + expect(fibonacci(6)).toBe(8) 19 + expect(fibonacci(7)).toBe(13) 20 + expect(fibonacci(8)).toBe(21) 21 + expect(fibonacci(9)).toMatchInlineSnapshot('34') 22 + }) 23 + }
+2
test/core/src/in-source/index.ts
··· 1 + export * from './add' 2 + export * from './fibonacci'
test/core/src/wasm/add.wasm

This is a binary file and will not be displayed.

+3
test/core/src/web-worker/eventListenerWorker.ts
··· 1 + self.addEventListener('message', (e) => { 2 + self.postMessage(`${e.data} world`) 3 + })
+3
test/core/src/web-worker/objectWorker.ts
··· 1 + self.onmessage = (e) => { 2 + self.postMessage(e.data) 3 + }
+3
test/core/src/web-worker/selfWorker.ts
··· 1 + import subSelf from './selfWorkerDep' 2 + 3 + self.postMessage(subSelf === self)
+1
test/core/src/web-worker/selfWorkerDep.ts
··· 1 + export default self
+10
test/core/src/web-worker/sharedWorker.ts
··· 1 + self.addEventListener('connect', (event) => { 2 + const e = event as MessageEvent 3 + const port = e.ports[0] 4 + 5 + port.onmessage = (e) => { 6 + port.postMessage(e.data) 7 + } 8 + 9 + port.start() 10 + })
+3
test/core/src/web-worker/worker.ts
··· 1 + self.onmessage = (e) => { 2 + self.postMessage(`${e.data} world`) 3 + }
+7
test/core/test/__snapshots__/snapshot-concurrent-sync.test.ts.snap
··· 1 + // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 + 3 + exports[`concurrent suite > snapshot 1`] = ` 4 + { 5 + "foo": "bar", 6 + } 7 + `;
+9
test/core/test/__snapshots__/snapshot-concurrent.test.ts.snap
··· 1 + // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 + 3 + exports[`four 1`] = `"four"`; 4 + 5 + exports[`one 1`] = `"one"`; 6 + 7 + exports[`three 1`] = `"three"`; 8 + 9 + exports[`two 1`] = `"two"`;
+11
test/core/test/__snapshots__/snapshot.test.ts.snap
··· 7 7 " 8 8 `; 9 9 10 + exports[`multiline strings 1`] = ` 11 + " 12 + export default function () { 13 + function Foo() { 14 + } 15 + 16 + return Foo; 17 + } 18 + " 19 + `; 20 + 10 21 exports[`object 1`] = ` 11 22 { 12 23 "this": {
+9
test/core/test/env-glob-dom/env-glob.overrides.spec.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + /** 4 + * @vitest-environment edge-runtime 5 + */ 6 + 7 + test('glob on folder overrides', () => { 8 + expect(expect.getState().environment).toBe('edge-runtime') 9 + })
+6
test/core/test/env-glob-dom/env-glob.spec.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('glob on folder', () => { 4 + expect(typeof window).not.toBe('undefined') 5 + expect(expect.getState().environment).toBe('jsdom') 6 + })
+9
test/core/test/environments/custom-env.test.ts
··· 1 + // @vitest-environment custom 2 + 3 + import { expect, test } from 'vitest' 4 + 5 + test('custom env is defined', () => { 6 + expect(expect.getState().environment).toBe('custom') 7 + expect((globalThis as any).testEnvironment).toBe('custom') 8 + expect((globalThis as any).option).toBe('config-option') 9 + })
-6
test/env-glob/test/dom/base.spec.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('glob on folder', () => { 4 - expect(typeof window).not.toBe('undefined') 5 - expect(expect.getState().environment).toBe('jsdom') 6 - })
-9
test/env-glob/test/dom/overrides.spec.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - /** 4 - * @vitest-environment edge-runtime 5 - */ 6 - 7 - test('glob on folder overrides', () => { 8 - expect(expect.getState().environment).toBe('edge-runtime') 9 - })
-85
test/failing/fixtures/expects/soft.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - interface CustomMatchers<R = unknown> { 4 - toBeDividedBy(divisor: number): R 5 - } 6 - 7 - declare module 'vitest' { 8 - interface Assertion<T = any> extends CustomMatchers<T> {} 9 - } 10 - 11 - expect.extend({ 12 - toBeDividedBy(received, divisor) { 13 - const pass = received % divisor === 0 14 - if (pass) { 15 - return { 16 - message: () => 17 - `expected ${received} not to be divisible by ${divisor}`, 18 - pass: true, 19 - } 20 - } 21 - else { 22 - return { 23 - message: () => 24 - `expected ${received} to be divisible by ${divisor}`, 25 - pass: false, 26 - } 27 - } 28 - }, 29 - }) 30 - 31 - test('basic', () => { 32 - expect.soft(1).toBe(2) 33 - expect.soft(2).toBe(3) 34 - }) 35 - 36 - test('promise', async () => { 37 - await expect.soft( 38 - new Promise((resolve) => { 39 - setTimeout(() => { 40 - resolve(1) 41 - }) 42 - }), 43 - ).resolves.toBe(2) 44 - await expect.soft( 45 - new Promise((resolve) => { 46 - setTimeout(() => { 47 - resolve(2) 48 - }) 49 - }), 50 - ).resolves.toBe(3) 51 - }) 52 - 53 - test('with expect', () => { 54 - expect.soft(1).toEqual(2) 55 - expect(10).toEqual(20) 56 - expect.soft(2).toEqual(3) 57 - }) 58 - 59 - test('with expect.extend', () => { 60 - expect.soft(1).toEqual(2) 61 - expect.soft(3).toBeDividedBy(4) 62 - expect(5).toEqual(6) 63 - }) 64 - 65 - test('passed', () => { 66 - expect.soft(1).toEqual(1) 67 - expect(10).toEqual(10) 68 - expect.soft(2).toEqual(2) 69 - }) 70 - 71 - let num = 0 72 - test('retry will passed', () => { 73 - expect.soft(num += 1).toBe(3) 74 - expect.soft(num += 1).toBe(4) 75 - }, { 76 - retry: 1, 77 - }) 78 - 79 - num = 0 80 - test('retry will failed', () => { 81 - expect.soft(num += 1).toBe(4) 82 - expect.soft(num += 1).toBe(5) 83 - }, { 84 - retry: 1, 85 - })
-5
test/fails/fixtures/.dot-folder/dot-test.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('check that tests inside folder with . is run', () => { 4 - expect(true).toBe(false) 5 - })
-14
test/fails/fixtures/test-extend/circular-dependency.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - const myTest = test.extend<{ a: number; b: number }>({ 4 - a: async ({ b }, use) => { 5 - await use(b) 6 - }, 7 - b: async ({ a }, use) => { 8 - await use(a) 9 - }, 10 - }) 11 - 12 - myTest('', ({ a }) => { 13 - expect(a).toBe(0) 14 - })
-65
test/fails/fixtures/test-extend/fixture-error.test.ts
··· 1 - import { afterEach, beforeEach, describe, expectTypeOf, test, expect } from 'vitest' 2 - 3 - describe('error thrown in beforeEach fixtures', () => { 4 - const myTest = test.extend<{ a: never }>({ 5 - a: async () => { 6 - throw new Error('Error thrown in beforeEach fixture') 7 - }, 8 - }) 9 - 10 - // eslint-disable-next-line unused-imports/no-unused-vars 11 - beforeEach<{ a: never }>(({ a }) => {}) 12 - 13 - myTest('error is handled', () => {}) 14 - }) 15 - 16 - describe('error thrown in afterEach fixtures', () => { 17 - const myTest = test.extend<{ a: never }>({ 18 - a: async () => { 19 - throw new Error('Error thrown in afterEach fixture') 20 - }, 21 - }) 22 - 23 - // eslint-disable-next-line unused-imports/no-unused-vars 24 - afterEach<{ a: never }>(({ a }) => {}) 25 - 26 - myTest('fixture errors', () => { 27 - expectTypeOf(1).toEqualTypeOf<number>() 28 - }) 29 - }) 30 - 31 - describe('error thrown in test fixtures', () => { 32 - const myTest = test.extend<{ a: never }>({ 33 - a: async () => { 34 - throw new Error('Error thrown in test fixture') 35 - }, 36 - }) 37 - 38 - // eslint-disable-next-line unused-imports/no-unused-vars 39 - myTest('fixture errors', ({ a }) => {}) 40 - }) 41 - 42 - describe('correctly fails when test times out', () => { 43 - const myTest = test.extend<{ a: number }>({ 44 - a: async ({}, use) => { 45 - await use(2) 46 - }, 47 - }) 48 - myTest('test times out', async ({ a }) => { 49 - await new Promise((resolve) => setTimeout(resolve, 1000)) 50 - expect(a).toBe(2) 51 - }, 20) 52 - }) 53 - 54 - describe('error thrown during fixture teardown', () => { 55 - const myTest = test.extend<{ a: string }>({ 56 - a: async ({}, use) => { 57 - await use("hello"); 58 - throw new Error('Error fixture teardown') 59 - }, 60 - }) 61 - 62 - myTest('no error in test', ({ a }) => { 63 - expect(a).toBe("hello"); 64 - }) 65 - })
-6
test/fails/fixtures/test-extend/fixture-rest-params.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test.extend({ 4 - // eslint-disable-next-line unused-imports/no-unused-vars 5 - a: async (...rest) => {}, 6 - })
-6
test/fails/fixtures/test-extend/fixture-rest-props.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test.extend({ 4 - // eslint-disable-next-line unused-imports/no-unused-vars 5 - a: async ({ ...rest }) => {}, 6 - })
-6
test/fails/fixtures/test-extend/fixture-without-destructuring.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test.extend({ 4 - // eslint-disable-next-line unused-imports/no-unused-vars 5 - a: async (context) => {}, 6 - })
-8
test/fails/fixtures/test-extend/test-rest-params.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - const myTest = test.extend({ a: 1 }) 4 - 5 - // eslint-disable-next-line unused-imports/no-unused-vars 6 - myTest('', (...rest) => { 7 - 8 - })
-8
test/fails/fixtures/test-extend/test-rest-props.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - const myTest = test.extend({ a: 1 }) 4 - 5 - // eslint-disable-next-line unused-imports/no-unused-vars 6 - myTest('', ({ ...rest }) => { 7 - 8 - })
-8
test/fails/fixtures/test-extend/test-without-destructuring.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - const myTest = test.extend({ a: 1 }) 4 - 5 - // eslint-disable-next-line unused-imports/no-unused-vars 6 - myTest('', (context) => { 7 - 8 - })
-82
test/fails/test/__snapshots__/runner.test.ts.snap
··· 1 - // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 - 3 - exports[`should fail .dot-folder/dot-test.test.ts > .dot-folder/dot-test.test.ts 1`] = `"AssertionError: expected true to be false // Object.is equality"`; 4 - 5 - exports[`should fail each-timeout.test.ts > each-timeout.test.ts 1`] = `"Error: Test timed out in 10ms."`; 6 - 7 - exports[`should fail empty.test.ts > empty.test.ts 1`] = `"Error: No test suite found in file <rootDir>/empty.test.ts"`; 8 - 9 - exports[`should fail expect.test.ts > expect.test.ts 1`] = `"AssertionError: expected 2 to deeply equal 3"`; 10 - 11 - exports[`should fail expect-soft.test.ts > expect-soft.test.ts 1`] = `"Error: expect.soft() can only be used inside a test"`; 12 - 13 - exports[`should fail expect-unreachable.test.ts > expect-unreachable.test.ts 1`] = `"AssertionError: expected "hi" not to be reached"`; 14 - 15 - exports[`should fail hook-timeout.test.ts > hook-timeout.test.ts 1`] = `"Error: Hook timed out in 10ms."`; 16 - 17 - exports[`should fail hooks-called.test.ts > hooks-called.test.ts 1`] = ` 18 - "Error: after all 19 - Error: before all" 20 - `; 21 - 22 - exports[`should fail inline-snapshop-inside-each.test.ts > inline-snapshop-inside-each.test.ts 1`] = ` 23 - "Error: InlineSnapshot cannot be used inside of test.each or describe.each 24 - Error: InlineSnapshot cannot be used inside of test.each or describe.each 25 - Error: InlineSnapshot cannot be used inside of test.each or describe.each 26 - Error: InlineSnapshot cannot be used inside of test.each or describe.each 27 - Error: InlineSnapshot cannot be used inside of test.each or describe.each" 28 - `; 29 - 30 - exports[`should fail mock-import-proxy-module.test.ts > mock-import-proxy-module.test.ts 1`] = `"Error: There are some problems in resolving the mocks API."`; 31 - 32 - exports[`should fail nested-suite.test.ts > nested-suite.test.ts 1`] = `"AssertionError: expected true to be false // Object.is equality"`; 33 - 34 - exports[`should fail primitive-error.test.ts > primitive-error.test.ts 1`] = `"Unknown Error: 42"`; 35 - 36 - exports[`should fail snapshot-with-not.test.ts > snapshot-with-not.test.ts 1`] = ` 37 - "Error: toThrowErrorMatchingInlineSnapshot cannot be used with "not" 38 - Error: toThrowErrorMatchingSnapshot cannot be used with "not" 39 - Error: toMatchInlineSnapshot cannot be used with "not" 40 - Error: toMatchFileSnapshot cannot be used with "not" 41 - Error: toMatchSnapshot cannot be used with "not"" 42 - `; 43 - 44 - exports[`should fail stall.test.ts > stall.test.ts 1`] = ` 45 - "TypeError: failure 46 - TypeError: failure 47 - TypeError: failure 48 - TypeError: failure" 49 - `; 50 - 51 - exports[`should fail test-extend/circular-dependency.test.ts > test-extend/circular-dependency.test.ts 1`] = `"Error: Circular fixture dependency detected: a <- b <- a"`; 52 - 53 - exports[`should fail test-extend/fixture-error.test.ts > test-extend/fixture-error.test.ts 1`] = ` 54 - "Error: Error fixture teardown 55 - Error: Test timed out in 20ms. 56 - Error: Error thrown in test fixture 57 - Error: Error thrown in afterEach fixture 58 - Error: Error thrown in beforeEach fixture" 59 - `; 60 - 61 - exports[`should fail test-extend/fixture-rest-params.test.ts > test-extend/fixture-rest-params.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "...rest"."`; 62 - 63 - exports[`should fail test-extend/fixture-rest-props.test.ts > test-extend/fixture-rest-props.test.ts 1`] = `"Error: Rest parameters are not supported in fixtures, received "...rest"."`; 64 - 65 - exports[`should fail test-extend/fixture-without-destructuring.test.ts > test-extend/fixture-without-destructuring.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "context"."`; 66 - 67 - exports[`should fail test-extend/test-rest-params.test.ts > test-extend/test-rest-params.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "...rest"."`; 68 - 69 - exports[`should fail test-extend/test-rest-props.test.ts > test-extend/test-rest-props.test.ts 1`] = `"Error: Rest parameters are not supported in fixtures, received "...rest"."`; 70 - 71 - exports[`should fail test-extend/test-without-destructuring.test.ts > test-extend/test-without-destructuring.test.ts 1`] = `"Error: The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "context"."`; 72 - 73 - exports[`should fail test-timeout.test.ts > test-timeout.test.ts 1`] = ` 74 - "Error: Test timed out in 200ms. 75 - Error: Test timed out in 100ms. 76 - Error: Test timed out in 10ms." 77 - `; 78 - 79 - exports[`should fail unhandled.test.ts > unhandled.test.ts 1`] = ` 80 - "Error: some error 81 - Error: Uncaught [Error: some error]" 82 - `;
-3
test/filters/fixtures-slash/test/basic.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test('example', () => {})
-5
test/filters/fixtures/test/dont-run-this.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('this will fail', () => { 4 - expect('This test should not be run').toBeFalsy() 5 - })
-5
test/filters/fixtures/test/example.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('this will pass', () => { 4 - expect(1 + 1).toBe(2) 5 - })
-5
test/filters/fixtures/test/filters.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('this will pass', () => { 4 - expect('This test should be run').toBeTruthy() 5 - })
-3
test/global-setup-fail/fixtures/globalSetup/error.js
··· 1 - export default function () { 2 - throw new Error('error') 3 - }
-53
test/run/pool-custom-fixtures/pool/custom-pool.ts
··· 1 - import type { File, Test } from 'vitest' 2 - import type { ProcessPool, Vitest } from 'vitest/node' 3 - import { createMethodsRPC } from 'vitest/node' 4 - import { getTasks } from '@vitest/runner/utils' 5 - import { normalize, relative } from 'pathe' 6 - 7 - export default (ctx: Vitest): ProcessPool => { 8 - const options = ctx.config.poolOptions?.custom as any 9 - return { 10 - name: 'custom', 11 - async runTests(specs) { 12 - ctx.logger.console.warn('[pool] printing:', options.print) 13 - ctx.logger.console.warn('[pool] array option', options.array) 14 - for await (const [project, file] of specs) { 15 - ctx.state.clearFiles(project) 16 - const methods = createMethodsRPC(project) 17 - ctx.logger.console.warn('[pool] running tests for', project.getName(), 'in', normalize(file).toLowerCase().replace(normalize(process.cwd()).toLowerCase(), '')) 18 - const path = relative(project.config.root, file) 19 - const taskFile: File = { 20 - id: `${path}${project.getName()}`, 21 - name: path, 22 - mode: 'run', 23 - meta: {}, 24 - projectName: project.getName(), 25 - filepath: file, 26 - type: 'suite', 27 - tasks: [], 28 - result: { 29 - state: 'pass', 30 - }, 31 - } 32 - const taskTest: Test = { 33 - type: 'test', 34 - name: 'custom test', 35 - id: 'custom-test', 36 - context: {} as any, 37 - suite: taskFile, 38 - mode: 'run', 39 - meta: {}, 40 - result: { 41 - state: 'pass', 42 - }, 43 - } 44 - taskFile.tasks.push(taskTest) 45 - await methods.onCollected([taskFile]) 46 - await methods.onTaskUpdate(getTasks(taskFile).map(task => [task.id, task.result, task.meta])) 47 - } 48 - }, 49 - close() { 50 - ctx.logger.console.warn('[pool] custom pool is closed!') 51 - }, 52 - } 53 - }
-1
test/run/pool-custom-fixtures/tests/custom-not-run.spec.ts
··· 1 - throw new Error('this file is not actually running')
-5
test/run/pool-custom-fixtures/tests/custom-run.threads.spec.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('correctly runs threads test while there is a custom pool', () => { 4 - expect(1 + 1).toBe(2) 5 - })
-3
test/setup/tests/fixtures/console.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test('empty', () => {})
-7
test/snapshots/test/__snapshots__/shapshots-concurrent-sync.test.ts.snap
··· 1 - // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 - 3 - exports[`concurrent suite > snapshot 1`] = ` 4 - Object { 5 - "foo": "bar", 6 - } 7 - `;
-9
test/snapshots/test/__snapshots__/shapshots-concurrent.test.ts.snap
··· 1 - // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 - 3 - exports[`four 1`] = `"four"`; 4 - 5 - exports[`one 1`] = `"one"`; 6 - 7 - exports[`three 1`] = `"three"`; 8 - 9 - exports[`two 1`] = `"two"`;
-102
test/snapshots/test/__snapshots__/shapshots.test.ts.snap
··· 1 - // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 - 3 - exports[`concurrent snapshot update 1`] = ` 4 - "import { it } from 'vitest' 5 - 6 - it.concurrent('1st', ({ expect }) => { 7 - expect('hi1').toMatchInlineSnapshot(\`"hi1"\`) 8 - }) 9 - 10 - it.concurrent('2nd', ({ expect }) => { 11 - expect('hi2').toMatchInlineSnapshot(\`"hi2"\`) 12 - }) 13 - 14 - it.concurrent('3rd', ({ expect }) => { 15 - expect('hi3').toMatchInlineSnapshot(\`"hi3"\`) 16 - }) 17 - " 18 - `; 19 - 20 - exports[`js snapshots generated correctly 1`] = ` 21 - "import { describe, expect, test } from 'vitest' 22 - 23 - // when snapshots are generated Vitest reruns \`toMatchInlineSnapshot\` checks 24 - // please, don't commit generated snapshots 25 - describe('snapshots are generated in correct order', async () => { 26 - test('first snapshot', () => { 27 - expect({ foo: ['bar'] }).toMatchInlineSnapshot(\` 28 - Object { 29 - "foo": Array [ 30 - "bar", 31 - ], 32 - } 33 - \`) 34 - }) 35 - 36 - test('second snapshot', () => { 37 - expect({ foo: ['zed'] }).toMatchInlineSnapshot(\` 38 - Object { 39 - "foo": Array [ 40 - "zed", 41 - ], 42 - } 43 - \`) 44 - }) 45 - }) 46 - 47 - describe('snapshots with properties', () => { 48 - test('without snapshot', () => { 49 - expect({ foo: 'bar' }).toMatchInlineSnapshot({ foo: expect.any(String) }, \` 50 - Object { 51 - "foo": Any<String>, 52 - } 53 - \`) 54 - }) 55 - 56 - test('with snapshot', () => { 57 - expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, \` 58 - Object { 59 - "first": Object { 60 - "second": Object { 61 - "foo": Any<String>, 62 - }, 63 - }, 64 - } 65 - \`) 66 - }) 67 - 68 - test('mixed with and without snapshot', () => { 69 - expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, \` 70 - Object { 71 - "first": Object { 72 - "second": Object { 73 - "foo": Any<String>, 74 - }, 75 - }, 76 - } 77 - \`) 78 - 79 - expect({ first: { second: { foo: 'zed' } } }).toMatchInlineSnapshot(\` 80 - Object { 81 - "first": Object { 82 - "second": Object { 83 - "foo": "zed", 84 - }, 85 - }, 86 - } 87 - \`) 88 - }) 89 - }) 90 - " 91 - `; 92 - 93 - exports[`multiline strings 1`] = ` 94 - " 95 - export default function () { 96 - function Foo() { 97 - } 98 - 99 - return Foo; 100 - } 101 - " 102 - `;
+91
test/snapshots/test/__snapshots__/snapshots.test.ts.snap
··· 1 + // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 + 3 + exports[`concurrent snapshot update 1`] = ` 4 + "import { it } from 'vitest' 5 + 6 + it.concurrent('1st', ({ expect }) => { 7 + expect('hi1').toMatchInlineSnapshot(\`"hi1"\`) 8 + }) 9 + 10 + it.concurrent('2nd', ({ expect }) => { 11 + expect('hi2').toMatchInlineSnapshot(\`"hi2"\`) 12 + }) 13 + 14 + it.concurrent('3rd', ({ expect }) => { 15 + expect('hi3').toMatchInlineSnapshot(\`"hi3"\`) 16 + }) 17 + " 18 + `; 19 + 20 + exports[`js snapshots generated correctly 1`] = ` 21 + "import { describe, expect, test } from 'vitest' 22 + 23 + // when snapshots are generated Vitest reruns \`toMatchInlineSnapshot\` checks 24 + // please, don't commit generated snapshots 25 + describe('snapshots are generated in correct order', async () => { 26 + test('first snapshot', () => { 27 + expect({ foo: ['bar'] }).toMatchInlineSnapshot(\` 28 + Object { 29 + "foo": Array [ 30 + "bar", 31 + ], 32 + } 33 + \`) 34 + }) 35 + 36 + test('second snapshot', () => { 37 + expect({ foo: ['zed'] }).toMatchInlineSnapshot(\` 38 + Object { 39 + "foo": Array [ 40 + "zed", 41 + ], 42 + } 43 + \`) 44 + }) 45 + }) 46 + 47 + describe('snapshots with properties', () => { 48 + test('without snapshot', () => { 49 + expect({ foo: 'bar' }).toMatchInlineSnapshot({ foo: expect.any(String) }, \` 50 + Object { 51 + "foo": Any<String>, 52 + } 53 + \`) 54 + }) 55 + 56 + test('with snapshot', () => { 57 + expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, \` 58 + Object { 59 + "first": Object { 60 + "second": Object { 61 + "foo": Any<String>, 62 + }, 63 + }, 64 + } 65 + \`) 66 + }) 67 + 68 + test('mixed with and without snapshot', () => { 69 + expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, \` 70 + Object { 71 + "first": Object { 72 + "second": Object { 73 + "foo": Any<String>, 74 + }, 75 + }, 76 + } 77 + \`) 78 + 79 + expect({ first: { second: { foo: 'zed' } } }).toMatchInlineSnapshot(\` 80 + Object { 81 + "first": Object { 82 + "second": Object { 83 + "foo": "zed", 84 + }, 85 + }, 86 + } 87 + \`) 88 + }) 89 + }) 90 + " 91 + `;
-170
test/stacktraces/test/__snapshots__/runner.test.ts.snap
··· 1 - // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 - 3 - exports[`stacktrace filtering > filters stacktraces > stacktrace-filtering 1`] = ` 4 - "⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ 5 - 6 - FAIL error-with-stack.test.js > error in deps 7 - Error: Something truly horrible has happened! 8 - ❯ d error-with-stack.test.js:20:9 9 - 18| 10 - 19| function d() { 11 - 20| throw new Error('Something truly horrible has happened!') 12 - | ^ 13 - 21| } 14 - 22| 15 - ❯ c error-with-stack.test.js:16:3 16 - ❯ a error-with-stack.test.js:8:3 17 - ❯ error-with-stack.test.js:4:3 18 - 19 - ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 20 - 21 - " 22 - `; 23 - 24 - exports[`stacktrace in vmThreads 1`] = ` 25 - "⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ 26 - 27 - FAIL error-with-stack.test.js > error in deps 28 - Error: Something truly horrible has happened! 29 - ❯ d error-with-stack.test.js:20:9 30 - 18| 31 - 19| function d() { 32 - 20| throw new Error('Something truly horrible has happened!') 33 - | ^ 34 - 21| } 35 - 22| 36 - ❯ c error-with-stack.test.js:16:3 37 - ❯ b error-with-stack.test.js:12:3 38 - ❯ a error-with-stack.test.js:8:3 39 - ❯ error-with-stack.test.js:4:3 40 - 41 - ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 42 - 43 - " 44 - `; 45 - 46 - exports[`stacktrace should print error frame source file correctly > error-in-deps > error-in-deps 1`] = ` 47 - "⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯ 48 - 49 - FAIL error-in-deps.test.js > error in deps 50 - ReferenceError: bar is not defined 51 - ❯ Module.add foo.js:3:3 52 - 1| export function add() { 53 - 2| // eslint-disable-next-line no-undef 54 - 3| return bar() 55 - | ^ 56 - 4| } 57 - 5| 58 - ❯ error-in-deps.test.js:5:3 59 - 60 - ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 61 - 62 - " 63 - `; 64 - 65 - exports[`stacktraces should pick error frame if present > frame.spec.imba > frame.spec.imba 1`] = ` 66 - " FAIL frame.spec.imba [ frame.spec.imba ] 67 - imba-parser error: Unexpected 'CALL_END' 68 - 4 | test("1+1") do 69 - 5 | expect(1+1).toBe 2 70 - 6 | frame. 71 - | ^ 72 - 7 | 73 - " 74 - `; 75 - 76 - exports[`stacktraces should respect sourcemaps > add.test.ts > add.test.ts 1`] = ` 77 - " ❯ add.test.ts:12:24 78 - 10| 79 - 11| it('add', () => { 80 - 12| expect(add(a.count)).toBe(100) 81 - | ^ 82 - 13| expect(add(1)).toBe(1) 83 - 14| return expect(add(1, 2, 3)).toBe(6) 84 - " 85 - `; 86 - 87 - exports[`stacktraces should respect sourcemaps > add-in-imba.test.imba > add-in-imba.test.imba 1`] = ` 88 - " ❯ add-in-imba.test.imba:8:17 89 - 6| it "add", do 90 - 7| expect(add()).toBe 0 91 - 8| expect(add(1)).toBe 3 92 - | ^ 93 - 9| expect(add(1, 2, 3)).toBe 6 94 - 10| 95 - " 96 - `; 97 - 98 - exports[`stacktraces should respect sourcemaps > add-in-js.test.js > add-in-js.test.js 1`] = ` 99 - " ❯ add-in-js.test.js:6:17 100 - 4| 101 - 5| it('add', () => { 102 - 6| expect(add()).toBe(100) 103 - | ^ 104 - 7| expect(add(1)).toBe(1) 105 - 8| return expect(add(1, 2, 3)).toBe(6) 106 - " 107 - `; 108 - 109 - exports[`stacktraces should respect sourcemaps > error-in-deps.test.js > error-in-deps.test.js 1`] = ` 110 - " ❯ error-in-deps.test.js:5:3 111 - 112 - ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ 113 - 114 - " 115 - `; 116 - 117 - exports[`stacktraces should respect sourcemaps > error-with-stack.test.js > error-with-stack.test.js 1`] = ` 118 - " ❯ d error-with-stack.test.js:20:9 119 - 18| 120 - 19| function d() { 121 - 20| throw new Error('Something truly horrible has happened!') 122 - | ^ 123 - 21| } 124 - 22| 125 - ❯ c error-with-stack.test.js:16:3" 126 - `; 127 - 128 - exports[`stacktraces should respect sourcemaps > mocked-global.test.js > mocked-global.test.js 1`] = ` 129 - " ❯ mocked-global.test.js:6:13 130 - 4| 131 - 5| test('failed', () => { 132 - 6| expect(1).toBe(2) 133 - | ^ 134 - 7| }) 135 - 8| 136 - " 137 - `; 138 - 139 - exports[`stacktraces should respect sourcemaps > mocked-imported.test.js > mocked-imported.test.js 1`] = ` 140 - " ❯ mocked-imported.test.js:6:13 141 - 4| 142 - 5| test('failed', () => { 143 - 6| expect(1).toBe(2) 144 - | ^ 145 - 7| }) 146 - 8| 147 - " 148 - `; 149 - 150 - exports[`stacktraces should respect sourcemaps > mocked-imported.test.ts > mocked-imported.test.ts 1`] = ` 151 - " ❯ mocked-imported.test.ts:6:13 152 - 4| 153 - 5| test('failed', () => { 154 - 6| expect(1).toBe(2) 155 - | ^ 156 - 7| }) 157 - 8| 158 - " 159 - `; 160 - 161 - exports[`stacktraces should respect sourcemaps > reset-modules.test.ts > reset-modules.test.ts 1`] = ` 162 - " ❯ reset-modules.test.ts:16:26 163 - 14| expect(2 + 1).eq(3) 164 - 15| assert.equal(Math.sqrt(4), 2) 165 - 16| expect(Math.sqrt(4)).toBe(1) 166 - | ^ 167 - 17| }) 168 - 18| }) 169 - " 170 - `;
-12
test/vite-config/src/test/root.test.ts
··· 1 - import { expect, it, vi } from 'vitest' 2 - import { foo } from '../src' 3 - 4 - vi.mock('../src.ts', () => ({ foo: 'baz' })) 5 - 6 - it('should work', () => { 7 - expect(1).toBe(1) 8 - }) 9 - 10 - it('mocking with root works', () => { 11 - expect(foo).toBe('baz') 12 - })
-5
test/vite-node/deps/dep1/package.json
··· 1 - { 2 - "name": "@vitest/test-dep1", 3 - "type": "module", 4 - "exports": "./esm/index.js" 5 - }
-1
test/vite-node/deps/dep2/index.js
··· 1 - export { data } from '@vitest/test-dep1'
-8
test/vite-node/deps/dep2/package.json
··· 1 - { 2 - "name": "@vitest/test-dep2", 3 - "type": "module", 4 - "exports": "./index.js", 5 - "dependencies": { 6 - "@vitest/test-dep1": "file:../dep1" 7 - } 8 - }
-7
test/vm-threads/src/external/default-cjs.cjs
··· 1 - module.exports = { 2 - a: 'a', 3 - b: 'b', 4 - object: { 5 - h: 'h', 6 - }, 7 - }
-2
test/vm-threads/src/external/export-default-cjs.js
··· 1 - export * from './default-cjs.cjs' 2 - export { default } from './default-cjs.cjs'
-2
test/vm-threads/src/external/export-nested-default-cjs.js
··· 1 - export * from './nested-default-cjs.cjs' 2 - export { default } from './nested-default-cjs.cjs'
-8
test/vm-threads/src/external/nested-default-cjs.cjs
··· 1 - exports.default = { 2 - a: 'a', 3 - b: 'b', 4 - object: { 5 - h: 'h', 6 - }, 7 - } 8 - Object.defineProperty(exports, '__esModule', { value: true, enumerable: false })
-15
test/vm-threads/src/external/not-found.js
··· 1 - export async function importPackage() { 2 - await import('@vitest/non-existing-package') 3 - } 4 - 5 - export async function importPath() { 6 - await import('./non-existing-path') 7 - } 8 - 9 - export async function importBuiltin() { 10 - await import('node:non-existing-builtin') 11 - } 12 - 13 - export async function importNamespace() { 14 - await import('non-existing-namespace:xyz') 15 - }
-3
test/vm-threads/src/external/package.json
··· 1 - { 2 - "type": "module" 3 - }
-1
test/vm-threads/src/external/primitive-cjs.cjs
··· 1 - module.exports = 'string'
-15
test/wasm-modules/src/wasm-bindgen-no-cyclic/README.md
··· 1 - The recent version of the wasm-bindgen bundler output does not use cyclic imports between wasm and js. 2 - 3 - For this non-cyclic version to work, both `index_bg.js` and `index_bg.wasm` need to be externalized 4 - since otherwise a dual package hazard on `index_bg.js` would make it non-functional. 5 - 6 - The code is copied from https://github.com/rustwasm/wasm-bindgen/tree/8198d2d25920e1f4fc593e9f8eb9d199e004d731/examples/hello_world 7 - 8 - ```sh 9 - npm i 10 - npm run build 11 - # then 12 - # 1. copy `examples/hello_world/pkg` to this directory 13 - # 2. add { "type": "module" } to `package.json` 14 - # (this will be automatically included after https://github.com/rustwasm/wasm-pack/pull/1061) 15 - ```
-6
test/wasm-modules/src/wasm-bindgen-no-cyclic/index.d.ts
··· 1 - /* tslint:disable */ 2 - /* eslint-disable */ 3 - /** 4 - * @param {string} name 5 - */ 6 - export function greet(name: string): void;
-4
test/wasm-modules/src/wasm-bindgen-no-cyclic/index.js
··· 1 - import * as wasm from "./index_bg.wasm"; 2 - import { __wbg_set_wasm } from "./index_bg.js"; 3 - __wbg_set_wasm(wasm); 4 - export * from "./index_bg.js";
-117
test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.js
··· 1 - let wasm; 2 - export function __wbg_set_wasm(val) { 3 - wasm = val; 4 - } 5 - 6 - 7 - const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; 8 - 9 - let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 10 - 11 - cachedTextDecoder.decode(); 12 - 13 - let cachedUint8Memory0 = null; 14 - 15 - function getUint8Memory0() { 16 - if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { 17 - cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); 18 - } 19 - return cachedUint8Memory0; 20 - } 21 - 22 - function getStringFromWasm0(ptr, len) { 23 - ptr = ptr >>> 0; 24 - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); 25 - } 26 - 27 - function logError(f, args) { 28 - try { 29 - return f.apply(this, args); 30 - } catch (e) { 31 - let error = (function () { 32 - try { 33 - return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); 34 - } catch(_) { 35 - return "<failed to stringify thrown value>"; 36 - } 37 - }()); 38 - console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); 39 - throw e; 40 - } 41 - } 42 - 43 - let WASM_VECTOR_LEN = 0; 44 - 45 - const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; 46 - 47 - let cachedTextEncoder = new lTextEncoder('utf-8'); 48 - 49 - const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' 50 - ? function (arg, view) { 51 - return cachedTextEncoder.encodeInto(arg, view); 52 - } 53 - : function (arg, view) { 54 - const buf = cachedTextEncoder.encode(arg); 55 - view.set(buf); 56 - return { 57 - read: arg.length, 58 - written: buf.length 59 - }; 60 - }); 61 - 62 - function passStringToWasm0(arg, malloc, realloc) { 63 - 64 - if (typeof(arg) !== 'string') throw new Error('expected a string argument'); 65 - 66 - if (realloc === undefined) { 67 - const buf = cachedTextEncoder.encode(arg); 68 - const ptr = malloc(buf.length, 1) >>> 0; 69 - getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); 70 - WASM_VECTOR_LEN = buf.length; 71 - return ptr; 72 - } 73 - 74 - let len = arg.length; 75 - let ptr = malloc(len, 1) >>> 0; 76 - 77 - const mem = getUint8Memory0(); 78 - 79 - let offset = 0; 80 - 81 - for (; offset < len; offset++) { 82 - const code = arg.charCodeAt(offset); 83 - if (code > 0x7F) break; 84 - mem[ptr + offset] = code; 85 - } 86 - 87 - if (offset !== len) { 88 - if (offset !== 0) { 89 - arg = arg.slice(offset); 90 - } 91 - ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; 92 - const view = getUint8Memory0().subarray(ptr + offset, ptr + len); 93 - const ret = encodeString(arg, view); 94 - if (ret.read !== arg.length) throw new Error('failed to pass whole string'); 95 - offset += ret.written; 96 - } 97 - 98 - WASM_VECTOR_LEN = offset; 99 - return ptr; 100 - } 101 - /** 102 - * @param {string} name 103 - */ 104 - export function greet(name) { 105 - const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 106 - const len0 = WASM_VECTOR_LEN; 107 - wasm.greet(ptr0, len0); 108 - } 109 - 110 - export function __wbg_alert_9ea5a791b0d4c7a3() { return logError(function (arg0, arg1) { 111 - alert(getStringFromWasm0(arg0, arg1)); 112 - }, arguments) }; 113 - 114 - export function __wbindgen_throw(arg0, arg1) { 115 - throw new Error(getStringFromWasm0(arg0, arg1)); 116 - }; 117 -
test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.wasm

This is a binary file and will not be displayed.

-6
test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts
··· 1 - /* tslint:disable */ 2 - /* eslint-disable */ 3 - export const memory: WebAssembly.Memory; 4 - export function greet(a: number, b: number): void; 5 - export function __wbindgen_malloc(a: number, b: number): number; 6 - export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
-20
test/wasm-modules/src/wasm-bindgen-no-cyclic/package.json
··· 1 - { 2 - "type": "module", 3 - "name": "hello_world", 4 - "collaborators": [ 5 - "The wasm-bindgen Developers" 6 - ], 7 - "version": "0.1.0", 8 - "files": [ 9 - "index_bg.wasm", 10 - "index.js", 11 - "index_bg.js", 12 - "index.d.ts" 13 - ], 14 - "module": "index.js", 15 - "types": "index.d.ts", 16 - "sideEffects": [ 17 - "./index.js", 18 - "./snippets/*" 19 - ] 20 - }
-1
test/wasm-modules/src/wasm-bindgen/README.md
··· 1 - copied from https://github.com/jestjs/jest/tree/28d32c6a1e48f1e4c946a8e6adbe2ae9af4103e3/e2e/native-esm/wasm-bindgen
-13
test/wasm-modules/src/wasm-bindgen/index.js
··· 1 - /** 2 - * Copyright (c) Meta Platforms, Inc. and affiliates. 3 - * 4 - * This source code is licensed under the MIT license found in the 5 - * LICENSE file in the root directory of this source tree. 6 - */ 7 - 8 - // folder source: https://github.com/rustwasm/wasm-bindgen/tree/4f865308afbe8d2463968457711ad356bae63b71/examples/hello_world 9 - // docs: https://rustwasm.github.io/docs/wasm-bindgen/examples/hello-world.html 10 - 11 - // eslint-disable-next-line unused-imports/no-unused-imports, import/newline-after-import 12 - import * as wasm from './index_bg.wasm' 13 - export * from './index_bg.js'
-148
test/wasm-modules/src/wasm-bindgen/index_bg.js
··· 1 - /* eslint-disable no-alert */ 2 - /* eslint-disable prefer-rest-params */ 3 - 4 - /** 5 - * Copyright (c) Meta Platforms, Inc. and affiliates. 6 - * 7 - * This source code is licensed under the MIT license found in the 8 - * LICENSE file in the root directory of this source tree. 9 - */ 10 - 11 - import * as wasm from './index_bg.wasm' 12 - 13 - const LTextDecoder 14 - = typeof TextDecoder === 'undefined' 15 - ? (0, module.require)('util').TextDecoder 16 - : TextDecoder 17 - 18 - const cachedTextDecoder = new LTextDecoder('utf-8', { 19 - fatal: true, 20 - ignoreBOM: true, 21 - }) 22 - 23 - cachedTextDecoder.decode() 24 - 25 - let cachedUint8Memory0 = new Uint8Array() 26 - 27 - function getUint8Memory0() { 28 - if (cachedUint8Memory0.byteLength === 0) 29 - cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer) 30 - 31 - return cachedUint8Memory0 32 - } 33 - 34 - function getStringFromWasm0(ptr, len) { 35 - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)) 36 - } 37 - 38 - function logError(f, args) { 39 - try { 40 - return f.apply(this, args) 41 - } 42 - catch (e) { 43 - const error = (function () { 44 - try { 45 - return e instanceof Error 46 - ? `${e.message}\n\nStack:\n${e.stack}` 47 - : e.toString() 48 - } 49 - catch (_) { 50 - return '<failed to stringify thrown value>' 51 - } 52 - })() 53 - console.error( 54 - 'wasm-bindgen: imported JS function that was not marked as `catch` threw an error:', 55 - error, 56 - ) 57 - throw e 58 - } 59 - } 60 - 61 - let WASM_VECTOR_LEN = 0 62 - 63 - const LTextEncoder 64 - = typeof TextEncoder === 'undefined' 65 - ? (0, module.require)('util').TextEncoder 66 - : TextEncoder 67 - 68 - const cachedTextEncoder = new LTextEncoder('utf-8') 69 - 70 - const encodeString 71 - = typeof cachedTextEncoder.encodeInto === 'function' 72 - ? function (arg, view) { 73 - return cachedTextEncoder.encodeInto(arg, view) 74 - } 75 - : function (arg, view) { 76 - const buf = cachedTextEncoder.encode(arg) 77 - view.set(buf) 78 - return { 79 - read: arg.length, 80 - written: buf.length, 81 - } 82 - } 83 - 84 - function passStringToWasm0(arg, malloc, realloc) { 85 - if (typeof arg !== 'string') 86 - throw new Error('expected a string argument') 87 - 88 - if (realloc === undefined) { 89 - const buf = cachedTextEncoder.encode(arg) 90 - const ptr = malloc(buf.length) 91 - getUint8Memory0() 92 - .subarray(ptr, ptr + buf.length) 93 - .set(buf) 94 - WASM_VECTOR_LEN = buf.length 95 - return ptr 96 - } 97 - 98 - let len = arg.length 99 - let ptr = malloc(len) 100 - 101 - const mem = getUint8Memory0() 102 - 103 - let offset = 0 104 - 105 - for (; offset < len; offset++) { 106 - const code = arg.charCodeAt(offset) 107 - if (code > 0x7F) 108 - break 109 - mem[ptr + offset] = code 110 - } 111 - 112 - if (offset !== len) { 113 - if (offset !== 0) 114 - arg = arg.slice(offset) 115 - 116 - ptr = realloc(ptr, len, (len = offset + arg.length * 3)) 117 - const view = getUint8Memory0().subarray(ptr + offset, ptr + len) 118 - const ret = encodeString(arg, view) 119 - if (ret.read !== arg.length) 120 - throw new Error('failed to pass whole string') 121 - offset += ret.written 122 - } 123 - 124 - WASM_VECTOR_LEN = offset 125 - return ptr 126 - } 127 - /** 128 - * @param {string} name 129 - */ 130 - export function greet(name) { 131 - const ptr0 = passStringToWasm0( 132 - name, 133 - wasm.__wbindgen_malloc, 134 - wasm.__wbindgen_realloc, 135 - ) 136 - const len0 = WASM_VECTOR_LEN 137 - wasm.greet(ptr0, len0) 138 - } 139 - 140 - export function __wbg_alert_9ea5a791b0d4c7a3() { 141 - return logError((arg0, arg1) => { 142 - alert(getStringFromWasm0(arg0, arg1)) 143 - }, arguments) 144 - } 145 - 146 - export function __wbindgen_throw(arg0, arg1) { 147 - throw new Error(getStringFromWasm0(arg0, arg1)) 148 - }
test/wasm-modules/src/wasm-bindgen/index_bg.wasm

This is a binary file and will not be displayed.

-3
test/wasm-modules/src/wasm-bindgen/package.json
··· 1 - { 2 - "type": "module" 3 - }
-5
test/ws-api/fixtures/server-url/basic.test.ts
··· 1 - import { expect, test } from "vitest"; 2 - 3 - test("basic", () => { 4 - expect(1).toBe(1); 5 - })
-11
test/ws-api/fixtures/server-url/vitest.config.ts
··· 1 - import { defineConfig } from 'vitest/config' 2 - import basicSsl from '@vitejs/plugin-basic-ssl' 3 - 4 - // test https by 5 - // TEST_HTTPS=1 pnpm test --root fixtures/server-url --api 6 - 7 - export default defineConfig({ 8 - plugins: [ 9 - !!process.env.TEST_HTTPS && basicSsl(), 10 - ], 11 - })
-1
test/changed/fixtures/related/src/sourceA.ts
··· 1 - export const A = 'A'
-1
test/changed/fixtures/related/src/sourceB.ts
··· 1 - export const B = 'B'
-2
test/changed/fixtures/related/src/sourceC.ts
··· 1 - // re-exporting for deep changed detection 2 - export { A } from './sourceA'
-4
test/changed/fixtures/related/src/sourceD.ts
··· 1 - // import and re-exporting for deep changed detection 2 - import { A as sourceA } from './sourceA' 3 - 4 - export const A = sourceA
+53
test/cli/fixtures/custom-pool/pool/custom-pool.ts
··· 1 + import type { File, Test } from 'vitest' 2 + import type { ProcessPool, Vitest } from 'vitest/node' 3 + import { createMethodsRPC } from 'vitest/node' 4 + import { getTasks } from '@vitest/runner/utils' 5 + import { normalize, relative } from 'pathe' 6 + 7 + export default (ctx: Vitest): ProcessPool => { 8 + const options = ctx.config.poolOptions?.custom as any 9 + return { 10 + name: 'custom', 11 + async runTests(specs) { 12 + ctx.logger.console.warn('[pool] printing:', options.print) 13 + ctx.logger.console.warn('[pool] array option', options.array) 14 + for await (const [project, file] of specs) { 15 + ctx.state.clearFiles(project) 16 + const methods = createMethodsRPC(project) 17 + ctx.logger.console.warn('[pool] running tests for', project.getName(), 'in', normalize(file).toLowerCase().replace(normalize(process.cwd()).toLowerCase(), '')) 18 + const path = relative(project.config.root, file) 19 + const taskFile: File = { 20 + id: `${path}${project.getName()}`, 21 + name: path, 22 + mode: 'run', 23 + meta: {}, 24 + projectName: project.getName(), 25 + filepath: file, 26 + type: 'suite', 27 + tasks: [], 28 + result: { 29 + state: 'pass', 30 + }, 31 + } 32 + const taskTest: Test = { 33 + type: 'test', 34 + name: 'custom test', 35 + id: 'custom-test', 36 + context: {} as any, 37 + suite: taskFile, 38 + mode: 'run', 39 + meta: {}, 40 + result: { 41 + state: 'pass', 42 + }, 43 + } 44 + taskFile.tasks.push(taskTest) 45 + await methods.onCollected([taskFile]) 46 + await methods.onTaskUpdate(getTasks(taskFile).map(task => [task.id, task.result, task.meta])) 47 + } 48 + }, 49 + close() { 50 + ctx.logger.console.warn('[pool] custom pool is closed!') 51 + }, 52 + } 53 + }
+1
test/cli/fixtures/custom-pool/tests/custom-not-run.spec.ts
··· 1 + throw new Error('this file is not actually running')
+5
test/cli/fixtures/custom-pool/tests/custom-run.threads.spec.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('correctly runs threads test while there is a custom pool', () => { 4 + expect(1 + 1).toBe(2) 5 + })
+85
test/cli/fixtures/expect-soft/expects/soft.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + interface CustomMatchers<R = unknown> { 4 + toBeDividedBy(divisor: number): R 5 + } 6 + 7 + declare module 'vitest' { 8 + interface Assertion<T = any> extends CustomMatchers<T> {} 9 + } 10 + 11 + expect.extend({ 12 + toBeDividedBy(received, divisor) { 13 + const pass = received % divisor === 0 14 + if (pass) { 15 + return { 16 + message: () => 17 + `expected ${received} not to be divisible by ${divisor}`, 18 + pass: true, 19 + } 20 + } 21 + else { 22 + return { 23 + message: () => 24 + `expected ${received} to be divisible by ${divisor}`, 25 + pass: false, 26 + } 27 + } 28 + }, 29 + }) 30 + 31 + test('basic', () => { 32 + expect.soft(1).toBe(2) 33 + expect.soft(2).toBe(3) 34 + }) 35 + 36 + test('promise', async () => { 37 + await expect.soft( 38 + new Promise((resolve) => { 39 + setTimeout(() => { 40 + resolve(1) 41 + }) 42 + }), 43 + ).resolves.toBe(2) 44 + await expect.soft( 45 + new Promise((resolve) => { 46 + setTimeout(() => { 47 + resolve(2) 48 + }) 49 + }), 50 + ).resolves.toBe(3) 51 + }) 52 + 53 + test('with expect', () => { 54 + expect.soft(1).toEqual(2) 55 + expect(10).toEqual(20) 56 + expect.soft(2).toEqual(3) 57 + }) 58 + 59 + test('with expect.extend', () => { 60 + expect.soft(1).toEqual(2) 61 + expect.soft(3).toBeDividedBy(4) 62 + expect(5).toEqual(6) 63 + }) 64 + 65 + test('passed', () => { 66 + expect.soft(1).toEqual(1) 67 + expect(10).toEqual(10) 68 + expect.soft(2).toEqual(2) 69 + }) 70 + 71 + let num = 0 72 + test('retry will passed', () => { 73 + expect.soft(num += 1).toBe(3) 74 + expect.soft(num += 1).toBe(4) 75 + }, { 76 + retry: 1, 77 + }) 78 + 79 + num = 0 80 + test('retry will failed', () => { 81 + expect.soft(num += 1).toBe(4) 82 + expect.soft(num += 1).toBe(5) 83 + }, { 84 + retry: 1, 85 + })
+5
test/cli/fixtures/fails/.dot-folder/dot-test.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('check that tests inside folder with . is run', () => { 4 + expect(true).toBe(false) 5 + })
+14
test/cli/fixtures/fails/test-extend/circular-dependency.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + const myTest = test.extend<{ a: number; b: number }>({ 4 + a: async ({ b }, use) => { 5 + await use(b) 6 + }, 7 + b: async ({ a }, use) => { 8 + await use(a) 9 + }, 10 + }) 11 + 12 + myTest('', ({ a }) => { 13 + expect(a).toBe(0) 14 + })
+65
test/cli/fixtures/fails/test-extend/fixture-error.test.ts
··· 1 + import { afterEach, beforeEach, describe, expectTypeOf, test, expect } from 'vitest' 2 + 3 + describe('error thrown in beforeEach fixtures', () => { 4 + const myTest = test.extend<{ a: never }>({ 5 + a: async () => { 6 + throw new Error('Error thrown in beforeEach fixture') 7 + }, 8 + }) 9 + 10 + // eslint-disable-next-line unused-imports/no-unused-vars 11 + beforeEach<{ a: never }>(({ a }) => {}) 12 + 13 + myTest('error is handled', () => {}) 14 + }) 15 + 16 + describe('error thrown in afterEach fixtures', () => { 17 + const myTest = test.extend<{ a: never }>({ 18 + a: async () => { 19 + throw new Error('Error thrown in afterEach fixture') 20 + }, 21 + }) 22 + 23 + // eslint-disable-next-line unused-imports/no-unused-vars 24 + afterEach<{ a: never }>(({ a }) => {}) 25 + 26 + myTest('fixture errors', () => { 27 + expectTypeOf(1).toEqualTypeOf<number>() 28 + }) 29 + }) 30 + 31 + describe('error thrown in test fixtures', () => { 32 + const myTest = test.extend<{ a: never }>({ 33 + a: async () => { 34 + throw new Error('Error thrown in test fixture') 35 + }, 36 + }) 37 + 38 + // eslint-disable-next-line unused-imports/no-unused-vars 39 + myTest('fixture errors', ({ a }) => {}) 40 + }) 41 + 42 + describe('correctly fails when test times out', () => { 43 + const myTest = test.extend<{ a: number }>({ 44 + a: async ({}, use) => { 45 + await use(2) 46 + }, 47 + }) 48 + myTest('test times out', async ({ a }) => { 49 + await new Promise((resolve) => setTimeout(resolve, 1000)) 50 + expect(a).toBe(2) 51 + }, 20) 52 + }) 53 + 54 + describe('error thrown during fixture teardown', () => { 55 + const myTest = test.extend<{ a: string }>({ 56 + a: async ({}, use) => { 57 + await use("hello"); 58 + throw new Error('Error fixture teardown') 59 + }, 60 + }) 61 + 62 + myTest('no error in test', ({ a }) => { 63 + expect(a).toBe("hello"); 64 + }) 65 + })
+6
test/cli/fixtures/fails/test-extend/fixture-rest-params.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test.extend({ 4 + // eslint-disable-next-line unused-imports/no-unused-vars 5 + a: async (...rest) => {}, 6 + })
+6
test/cli/fixtures/fails/test-extend/fixture-rest-props.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test.extend({ 4 + // eslint-disable-next-line unused-imports/no-unused-vars 5 + a: async ({ ...rest }) => {}, 6 + })
+6
test/cli/fixtures/fails/test-extend/fixture-without-destructuring.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test.extend({ 4 + // eslint-disable-next-line unused-imports/no-unused-vars 5 + a: async (context) => {}, 6 + })
+8
test/cli/fixtures/fails/test-extend/test-rest-params.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + const myTest = test.extend({ a: 1 }) 4 + 5 + // eslint-disable-next-line unused-imports/no-unused-vars 6 + myTest('', (...rest) => { 7 + 8 + })
+8
test/cli/fixtures/fails/test-extend/test-rest-props.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + const myTest = test.extend({ a: 1 }) 4 + 5 + // eslint-disable-next-line unused-imports/no-unused-vars 6 + myTest('', ({ ...rest }) => { 7 + 8 + })
+8
test/cli/fixtures/fails/test-extend/test-without-destructuring.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + const myTest = test.extend({ a: 1 }) 4 + 5 + // eslint-disable-next-line unused-imports/no-unused-vars 6 + myTest('', (context) => { 7 + 8 + })
+7
test/cli/fixtures/git-changed/related/not-related.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + import { B } from './src/sourceB' 3 + 4 + test('shouldn\'t run', () => { 5 + expect(B).toBe('B') 6 + expect.fail() 7 + })
+11
test/cli/fixtures/git-changed/related/related.test.ts
··· 1 + import { access } from 'node:fs' 2 + import { sep } from 'pathe' 3 + import { expect, test } from 'vitest' 4 + import { A } from './src/sourceA' 5 + 6 + test('A equals A', () => { 7 + expect(A).toBe('A') 8 + expect(typeof sep).toBe('string') 9 + // doesn't throw 10 + expect(typeof access).toBe('function') 11 + })
+1
test/cli/fixtures/git-changed/related/vitest.config.js
··· 1 + export default {}
+3
test/cli/fixtures/git-changed/workspace/package.json
··· 1 + { 2 + "type": "commonjs" 3 + }
+1
test/cli/fixtures/git-changed/workspace/vitest.config.mjs
··· 1 + export default {}
+3
test/cli/fixtures/git-changed/workspace/vitest.workspace.js
··· 1 + export default [ 2 + "packages/*/vitest.config.js", 3 + ];
+3
test/cli/fixtures/global-setup-fail/globalSetup/error.js
··· 1 + export default function () { 2 + throw new Error('error') 3 + }
+5
test/cli/fixtures/network-imports/public/slash@3.0.0.js
··· 1 + /* eslint-disable */ 2 + // copied from https://esm.sh/v133/slash@3.0.0/es2022/slash.mjs to reduce network issues in CI 3 + 4 + /* esm.sh - esbuild bundle(slash@3.0.0) es2022 production */ 5 + var a=Object.create;var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),E=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},u=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!p.call(e,n)&&n!==r&&d(e,n,{get:()=>t[n],enumerable:!(i=m(t,n))||i.enumerable});return e},o=(e,t,r)=>(u(e,t,"default"),r&&u(r,t,"default")),c=(e,t,r)=>(r=e!=null?a(g(e)):{},u(t||!e||!e.__esModule?d(r,"default",{value:e,enumerable:!0}):r,e));var f=A((h,_)=>{"use strict";_.exports=e=>{let t=/^\\\\\?\\/.test(e),r=/[^\u0000-\u0080]+/.test(e);return t||r?e:e.replace(/\\/g,"/")}});var s={};E(s,{default:()=>P});var L=c(f());o(s,c(f()));var{default:l,...N}=L,P=l!==void 0?l:N;export{P as default};
+3
test/cli/fixtures/restricted-fs/src/math.js
··· 1 + export function multiply(a, b) { 2 + return a * b 3 + }
+7
test/cli/fixtures/restricted-fs/tests/basic.spec.js
··· 1 + import { expect, it } from 'vitest' 2 + import { multiply } from '../src/math' 3 + 4 + it('2 x 2 = 4', () => { 5 + expect(multiply(2, 2)).toBe(4) 6 + expect(multiply(2, 2)).toBe(Math.sqrt(16)) 7 + })
+14
test/config/fixtures/bail/test/first.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('1 - first.test.ts - this should pass', async () => { 4 + await new Promise(resolve => setTimeout(resolve, 250)) 5 + expect(true).toBeTruthy() 6 + }) 7 + 8 + test('2 - first.test.ts - this should fail', () => { 9 + expect(false).toBeTruthy() 10 + }) 11 + 12 + test('3 - first.test.ts - this should be skipped', () => { 13 + expect(true).toBeTruthy() 14 + })
+17
test/config/fixtures/bail/test/second.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + // When using multi threads/forks the first test will start before failing.test.ts fails 4 + const isThreads = process.env.THREADS === 'true' 5 + 6 + test(`1 - second.test.ts - this should ${isThreads ? 'pass' : 'be skipped'}`, async () => { 7 + await new Promise(resolve => setTimeout(resolve, 1500)) 8 + expect(true).toBeTruthy() 9 + }) 10 + 11 + test('2 - second.test.ts - this should be skipped', () => { 12 + expect(true).toBeTruthy() 13 + }) 14 + 15 + test('3 - second.test.ts - this should be skipped', () => { 16 + expect(true).toBeTruthy() 17 + })
+1
test/config/fixtures/base-path/src/index.ts
··· 1 + export const foo = 'foo'
+14
test/config/fixtures/base-path/test/mocking-with-base.spec.ts
··· 1 + import { WorkerGlobalState, expect, test, vi } from 'vitest' 2 + import { foo } from '../src' 3 + 4 + vi.mock('../src', () => ({ 5 + foo: 'baz', 6 + })) 7 + 8 + // @ts-expect-error untyped global 9 + const state = globalThis.__vitest_worker__ as WorkerGlobalState 10 + 11 + test('module is mocked', () => { 12 + expect(foo).toBe('baz') 13 + expect(state.config.base).toBe('/some/base/url/') 14 + })
+38
test/config/fixtures/css/test/default-css.spec.ts
··· 1 + import { describe, expect, test } from 'vitest' 2 + import { useRemoveStyles } from '../utils' 3 + 4 + describe('don\'t process css by default', () => { 5 + useRemoveStyles() 6 + 7 + test('doesn\'t apply css', async () => { 8 + await import('../App.css') 9 + 10 + const element = document.createElement('div') 11 + element.className = 'main' 12 + const computed = window.getComputedStyle(element) 13 + expect(computed.display).toBe('block') 14 + expect(element).toMatchInlineSnapshot(` 15 + <div 16 + class="main" 17 + /> 18 + `) 19 + }) 20 + 21 + test('module is not processed', async () => { 22 + const { default: styles } = await import('../App.module.css') 23 + 24 + // HASH is static, based on the filepath to root 25 + expect(styles.module).toBe('_module_c70a46') 26 + expect(styles.someRandomValue).toBe('_someRandomValue_c70a46') 27 + const element = document.createElement('div') 28 + element.className = '_module_c70a46' 29 + const computed = window.getComputedStyle(element) 30 + expect(computed.display).toBe('block') 31 + expect(computed.width).toBe('') 32 + expect(element).toMatchInlineSnapshot(` 33 + <div 34 + class="_module_c70a46" 35 + /> 36 + `) 37 + }) 38 + })
+18
test/config/fixtures/css/test/non-scope-module.spec.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('module is processed', async () => { 4 + const { default: styles } = await import('../App.module.css') 5 + 6 + expect(styles.module).toBe('module') 7 + expect(styles.someRandomValue).toBeUndefined() 8 + const element = document.createElement('div') 9 + element.className = `${styles.main} ${styles.module}` 10 + const computed = window.getComputedStyle(element) 11 + expect(computed.display).toBe('flex') 12 + expect(computed.width).toBe('100px') 13 + expect(element).toMatchInlineSnapshot(` 14 + <div 15 + class="main module" 16 + /> 17 + `) 18 + })
+37
test/config/fixtures/css/test/process-css.spec.ts
··· 1 + import { describe, expect, test } from 'vitest' 2 + import { useRemoveStyles } from '../utils' 3 + 4 + describe('process only css, not module css', () => { 5 + useRemoveStyles() 6 + 7 + test('apply css', async () => { 8 + await import('../App.css') 9 + 10 + const element = document.createElement('div') 11 + element.className = 'main' 12 + const computed = window.getComputedStyle(element) 13 + expect(computed.display).toBe('flex') 14 + expect(element).toMatchInlineSnapshot(` 15 + <div 16 + class="main" 17 + /> 18 + `) 19 + }) 20 + 21 + test('module is not processed', async () => { 22 + const { default: styles } = await import('../App.module.css') 23 + 24 + expect(styles.module).toBe('_module_c70a46') 25 + expect(styles.someRandomValue).toBe('_someRandomValue_c70a46') 26 + const element = document.createElement('div') 27 + element.className = '_module_c70a46' 28 + const computed = window.getComputedStyle(element) 29 + expect(computed.display).toBe('block') 30 + expect(computed.width).toBe('') 31 + expect(element).toMatchInlineSnapshot(` 32 + <div 33 + class="_module_c70a46" 34 + /> 35 + `) 36 + }) 37 + })
+20
test/config/fixtures/css/test/process-inline.spec.ts
··· 1 + import { describe, expect, test } from 'vitest' 2 + import { useRemoveStyles } from '../utils' 3 + 4 + describe('processing inline css', () => { 5 + useRemoveStyles() 6 + 7 + test('doesn\'t apply css', async () => { 8 + await import('../App.module.css?inline') 9 + 10 + const element = document.createElement('div') 11 + element.className = 'main' 12 + const computed = window.getComputedStyle(element) 13 + expect(computed.display, 'css is not processed').toBe('block') 14 + }) 15 + 16 + test('returns a string', async () => { 17 + const { default: style } = await import('../App.module.css?inline') 18 + expect(typeof style).toBe('string') 19 + }) 20 + })
+32
test/config/fixtures/css/test/process-module.spec.ts
··· 1 + import { describe, expect, test } from 'vitest' 2 + import { useRemoveStyles } from '../utils' 3 + 4 + describe('processing module css', () => { 5 + useRemoveStyles() 6 + 7 + test('doesn\'t apply css', async () => { 8 + await import('../App.css') 9 + 10 + const element = document.createElement('div') 11 + element.className = 'main' 12 + const computed = window.getComputedStyle(element) 13 + expect(computed.display, 'css is not processed').toBe('block') 14 + }) 15 + 16 + test('module is processed', async () => { 17 + const { default: styles } = await import('../App.module.css') 18 + 19 + expect(styles.module).toBe('_module_c70a46') 20 + expect(styles.someRandomValue).toBeUndefined() 21 + const element = document.createElement('div') 22 + element.className = '_main_c70a46 _module_c70a46' 23 + const computed = window.getComputedStyle(element) 24 + expect(computed.display, 'css is processed').toBe('flex') 25 + expect(computed.width).toBe('100px') 26 + expect(element).toMatchInlineSnapshot(` 27 + <div 28 + class="_main_c70a46 _module_c70a46" 29 + /> 30 + `) 31 + }) 32 + })
+30
test/config/fixtures/css/test/scope-module.spec.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('module is processed and scoped', async () => { 4 + const { default: styles } = await import('../App.module.css') 5 + 6 + expect(styles.module).toMatch(/_module_\w+_\w/) 7 + expect(styles.someRandomValue).toBeUndefined() 8 + const element = document.createElement('div') 9 + element.className = 'module main' 10 + const computedStatic = window.getComputedStyle(element) 11 + expect(computedStatic.display).toBe('block') 12 + expect(computedStatic.width).toBe('') 13 + expect(element).toMatchInlineSnapshot(` 14 + <div 15 + class="module main" 16 + /> 17 + `) 18 + 19 + const mangledElement = document.createElement('div') 20 + 21 + mangledElement.className = `${styles.module} ${styles.main}` 22 + const computedModules = window.getComputedStyle(mangledElement) 23 + expect(computedModules.display).toBe('flex') 24 + expect(computedModules.width).toBe('100px') 25 + expect(mangledElement).toMatchInlineSnapshot(` 26 + <div 27 + class="_module_19cso_5 _main_19cso_1" 28 + /> 29 + `) 30 + })
+3
test/config/fixtures/filters-slash/test/basic.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test('example', () => {})
+5
test/config/fixtures/filters/test/config.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('this will pass', () => { 4 + expect('This test should be run').toBeTruthy() 5 + })
+5
test/config/fixtures/filters/test/dont-run-this.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('this will fail', () => { 4 + expect('This test should not be run').toBeFalsy() 5 + })
+5
test/config/fixtures/filters/test/example.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('this will pass', () => { 4 + expect(1 + 1).toBe(2) 5 + })
+3
test/config/fixtures/shard/test/1.test.js
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('1', () => expect(1).toBe(1))
+3
test/config/fixtures/shard/test/2.test.js
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('2', () => expect(1).toBe(1))
+3
test/config/fixtures/shard/test/3.test.js
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('3', () => expect(1).toBe(1))
+4
test/core/deps/dep1/esm/index.js
··· 1 + // esm/index.js was detected as isValidNodeImport(id) = false 2 + // event if package.json has type = module, 3 + // which causes dual package hazard when other external esm import esm/index.js. 4 + export const data = {}
+1
test/core/src/external/pkg-browser/index.d.ts
··· 1 + export default ''
+8
test/core/src/external/pkg-browser/package.json
··· 1 + { 2 + "type": "module", 3 + "exports": { 4 + "types": "./index.d.ts", 5 + "browser": "./web.js", 6 + "node": "./ssr.js" 7 + } 8 + }
+1
test/core/src/external/pkg-browser/ssr.js
··· 1 + export default 'ssr'
+1
test/core/src/external/pkg-browser/web.js
··· 1 + export default 'web'
+1
test/core/src/external/pkg-node/index.d.ts
··· 1 + export default ''
+8
test/core/src/external/pkg-node/package.json
··· 1 + { 2 + "type": "module", 3 + "exports": { 4 + "types": "./index.d.ts", 5 + "node": "./ssr.js", 6 + "browser": "./web.js" 7 + } 8 + }
+1
test/core/src/external/pkg-node/ssr.js
··· 1 + export default 'ssr'
+1
test/core/src/external/pkg-node/web.js
··· 1 + export default 'web'
+15
test/core/src/wasm/wasm-bindgen-no-cyclic/README.md
··· 1 + The recent version of the wasm-bindgen bundler output does not use cyclic imports between wasm and js. 2 + 3 + For this non-cyclic version to work, both `index_bg.js` and `index_bg.wasm` need to be externalized 4 + since otherwise a dual package hazard on `index_bg.js` would make it non-functional. 5 + 6 + The code is copied from https://github.com/rustwasm/wasm-bindgen/tree/8198d2d25920e1f4fc593e9f8eb9d199e004d731/examples/hello_world 7 + 8 + ```sh 9 + npm i 10 + npm run build 11 + # then 12 + # 1. copy `examples/hello_world/pkg` to this directory 13 + # 2. add { "type": "module" } to `package.json` 14 + # (this will be automatically included after https://github.com/rustwasm/wasm-pack/pull/1061) 15 + ```
+6
test/core/src/wasm/wasm-bindgen-no-cyclic/index.d.ts
··· 1 + /* tslint:disable */ 2 + /* eslint-disable */ 3 + /** 4 + * @param {string} name 5 + */ 6 + export function greet(name: string): void;
+4
test/core/src/wasm/wasm-bindgen-no-cyclic/index.js
··· 1 + import * as wasm from "./index_bg.wasm"; 2 + import { __wbg_set_wasm } from "./index_bg.js"; 3 + __wbg_set_wasm(wasm); 4 + export * from "./index_bg.js";
+117
test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.js
··· 1 + let wasm; 2 + export function __wbg_set_wasm(val) { 3 + wasm = val; 4 + } 5 + 6 + 7 + const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; 8 + 9 + let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 10 + 11 + cachedTextDecoder.decode(); 12 + 13 + let cachedUint8Memory0 = null; 14 + 15 + function getUint8Memory0() { 16 + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { 17 + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); 18 + } 19 + return cachedUint8Memory0; 20 + } 21 + 22 + function getStringFromWasm0(ptr, len) { 23 + ptr = ptr >>> 0; 24 + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); 25 + } 26 + 27 + function logError(f, args) { 28 + try { 29 + return f.apply(this, args); 30 + } catch (e) { 31 + let error = (function () { 32 + try { 33 + return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); 34 + } catch(_) { 35 + return "<failed to stringify thrown value>"; 36 + } 37 + }()); 38 + console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); 39 + throw e; 40 + } 41 + } 42 + 43 + let WASM_VECTOR_LEN = 0; 44 + 45 + const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; 46 + 47 + let cachedTextEncoder = new lTextEncoder('utf-8'); 48 + 49 + const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' 50 + ? function (arg, view) { 51 + return cachedTextEncoder.encodeInto(arg, view); 52 + } 53 + : function (arg, view) { 54 + const buf = cachedTextEncoder.encode(arg); 55 + view.set(buf); 56 + return { 57 + read: arg.length, 58 + written: buf.length 59 + }; 60 + }); 61 + 62 + function passStringToWasm0(arg, malloc, realloc) { 63 + 64 + if (typeof(arg) !== 'string') throw new Error('expected a string argument'); 65 + 66 + if (realloc === undefined) { 67 + const buf = cachedTextEncoder.encode(arg); 68 + const ptr = malloc(buf.length, 1) >>> 0; 69 + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); 70 + WASM_VECTOR_LEN = buf.length; 71 + return ptr; 72 + } 73 + 74 + let len = arg.length; 75 + let ptr = malloc(len, 1) >>> 0; 76 + 77 + const mem = getUint8Memory0(); 78 + 79 + let offset = 0; 80 + 81 + for (; offset < len; offset++) { 82 + const code = arg.charCodeAt(offset); 83 + if (code > 0x7F) break; 84 + mem[ptr + offset] = code; 85 + } 86 + 87 + if (offset !== len) { 88 + if (offset !== 0) { 89 + arg = arg.slice(offset); 90 + } 91 + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; 92 + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); 93 + const ret = encodeString(arg, view); 94 + if (ret.read !== arg.length) throw new Error('failed to pass whole string'); 95 + offset += ret.written; 96 + } 97 + 98 + WASM_VECTOR_LEN = offset; 99 + return ptr; 100 + } 101 + /** 102 + * @param {string} name 103 + */ 104 + export function greet(name) { 105 + const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 106 + const len0 = WASM_VECTOR_LEN; 107 + wasm.greet(ptr0, len0); 108 + } 109 + 110 + export function __wbg_alert_9ea5a791b0d4c7a3() { return logError(function (arg0, arg1) { 111 + alert(getStringFromWasm0(arg0, arg1)); 112 + }, arguments) }; 113 + 114 + export function __wbindgen_throw(arg0, arg1) { 115 + throw new Error(getStringFromWasm0(arg0, arg1)); 116 + }; 117 +
test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm

This is a binary file and will not be displayed.

+6
test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts
··· 1 + /* tslint:disable */ 2 + /* eslint-disable */ 3 + export const memory: WebAssembly.Memory; 4 + export function greet(a: number, b: number): void; 5 + export function __wbindgen_malloc(a: number, b: number): number; 6 + export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
+20
test/core/src/wasm/wasm-bindgen-no-cyclic/package.json
··· 1 + { 2 + "type": "module", 3 + "name": "hello_world", 4 + "collaborators": [ 5 + "The wasm-bindgen Developers" 6 + ], 7 + "version": "0.1.0", 8 + "files": [ 9 + "index_bg.wasm", 10 + "index.js", 11 + "index_bg.js", 12 + "index.d.ts" 13 + ], 14 + "module": "index.js", 15 + "types": "index.d.ts", 16 + "sideEffects": [ 17 + "./index.js", 18 + "./snippets/*" 19 + ] 20 + }
+1
test/core/src/wasm/wasm-bindgen/README.md
··· 1 + copied from https://github.com/jestjs/jest/tree/28d32c6a1e48f1e4c946a8e6adbe2ae9af4103e3/e2e/native-esm/wasm-bindgen
+13
test/core/src/wasm/wasm-bindgen/index.js
··· 1 + /** 2 + * Copyright (c) Meta Platforms, Inc. and affiliates. 3 + * 4 + * This source code is licensed under the MIT license found in the 5 + * LICENSE file in the root directory of this source tree. 6 + */ 7 + 8 + // folder source: https://github.com/rustwasm/wasm-bindgen/tree/4f865308afbe8d2463968457711ad356bae63b71/examples/hello_world 9 + // docs: https://rustwasm.github.io/docs/wasm-bindgen/examples/hello-world.html 10 + 11 + // eslint-disable-next-line unused-imports/no-unused-imports, import/newline-after-import 12 + import * as wasm from './index_bg.wasm' 13 + export * from './index_bg.js'
+148
test/core/src/wasm/wasm-bindgen/index_bg.js
··· 1 + /* eslint-disable no-alert */ 2 + /* eslint-disable prefer-rest-params */ 3 + 4 + /** 5 + * Copyright (c) Meta Platforms, Inc. and affiliates. 6 + * 7 + * This source code is licensed under the MIT license found in the 8 + * LICENSE file in the root directory of this source tree. 9 + */ 10 + 11 + import * as wasm from './index_bg.wasm' 12 + 13 + const LTextDecoder 14 + = typeof TextDecoder === 'undefined' 15 + ? (0, module.require)('util').TextDecoder 16 + : TextDecoder 17 + 18 + const cachedTextDecoder = new LTextDecoder('utf-8', { 19 + fatal: true, 20 + ignoreBOM: true, 21 + }) 22 + 23 + cachedTextDecoder.decode() 24 + 25 + let cachedUint8Memory0 = new Uint8Array() 26 + 27 + function getUint8Memory0() { 28 + if (cachedUint8Memory0.byteLength === 0) 29 + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer) 30 + 31 + return cachedUint8Memory0 32 + } 33 + 34 + function getStringFromWasm0(ptr, len) { 35 + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)) 36 + } 37 + 38 + function logError(f, args) { 39 + try { 40 + return f.apply(this, args) 41 + } 42 + catch (e) { 43 + const error = (function () { 44 + try { 45 + return e instanceof Error 46 + ? `${e.message}\n\nStack:\n${e.stack}` 47 + : e.toString() 48 + } 49 + catch (_) { 50 + return '<failed to stringify thrown value>' 51 + } 52 + })() 53 + console.error( 54 + 'wasm-bindgen: imported JS function that was not marked as `catch` threw an error:', 55 + error, 56 + ) 57 + throw e 58 + } 59 + } 60 + 61 + let WASM_VECTOR_LEN = 0 62 + 63 + const LTextEncoder 64 + = typeof TextEncoder === 'undefined' 65 + ? (0, module.require)('util').TextEncoder 66 + : TextEncoder 67 + 68 + const cachedTextEncoder = new LTextEncoder('utf-8') 69 + 70 + const encodeString 71 + = typeof cachedTextEncoder.encodeInto === 'function' 72 + ? function (arg, view) { 73 + return cachedTextEncoder.encodeInto(arg, view) 74 + } 75 + : function (arg, view) { 76 + const buf = cachedTextEncoder.encode(arg) 77 + view.set(buf) 78 + return { 79 + read: arg.length, 80 + written: buf.length, 81 + } 82 + } 83 + 84 + function passStringToWasm0(arg, malloc, realloc) { 85 + if (typeof arg !== 'string') 86 + throw new Error('expected a string argument') 87 + 88 + if (realloc === undefined) { 89 + const buf = cachedTextEncoder.encode(arg) 90 + const ptr = malloc(buf.length) 91 + getUint8Memory0() 92 + .subarray(ptr, ptr + buf.length) 93 + .set(buf) 94 + WASM_VECTOR_LEN = buf.length 95 + return ptr 96 + } 97 + 98 + let len = arg.length 99 + let ptr = malloc(len) 100 + 101 + const mem = getUint8Memory0() 102 + 103 + let offset = 0 104 + 105 + for (; offset < len; offset++) { 106 + const code = arg.charCodeAt(offset) 107 + if (code > 0x7F) 108 + break 109 + mem[ptr + offset] = code 110 + } 111 + 112 + if (offset !== len) { 113 + if (offset !== 0) 114 + arg = arg.slice(offset) 115 + 116 + ptr = realloc(ptr, len, (len = offset + arg.length * 3)) 117 + const view = getUint8Memory0().subarray(ptr + offset, ptr + len) 118 + const ret = encodeString(arg, view) 119 + if (ret.read !== arg.length) 120 + throw new Error('failed to pass whole string') 121 + offset += ret.written 122 + } 123 + 124 + WASM_VECTOR_LEN = offset 125 + return ptr 126 + } 127 + /** 128 + * @param {string} name 129 + */ 130 + export function greet(name) { 131 + const ptr0 = passStringToWasm0( 132 + name, 133 + wasm.__wbindgen_malloc, 134 + wasm.__wbindgen_realloc, 135 + ) 136 + const len0 = WASM_VECTOR_LEN 137 + wasm.greet(ptr0, len0) 138 + } 139 + 140 + export function __wbg_alert_9ea5a791b0d4c7a3() { 141 + return logError((arg0, arg1) => { 142 + alert(getStringFromWasm0(arg0, arg1)) 143 + }, arguments) 144 + } 145 + 146 + export function __wbindgen_throw(arg0, arg1) { 147 + throw new Error(getStringFromWasm0(arg0, arg1)) 148 + }
test/core/src/wasm/wasm-bindgen/index_bg.wasm

This is a binary file and will not be displayed.

+3
test/core/src/wasm/wasm-bindgen/package.json
··· 1 + { 2 + "type": "module" 3 + }
-5
test/cwd/.cache/projects/test/should-run.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('should run', () => { 4 - expect(1).toBe(1) 5 - })
-11
test/env-mixed/fixtures/project/test/happy-dom.test.ts
··· 1 - /** 2 - * @vitest-environment happy-dom 3 - */ 4 - 5 - import { expect, test } from 'vitest' 6 - 7 - test('Leaking globals not found', async () => { 8 - (globalThis as any).__leaking_from_happy_dom = 'leaking' 9 - expect((globalThis as any).__leaking_from_node).toBe(undefined) 10 - expect((globalThis as any).__leaking_from_jsdom).toBe(undefined) 11 - })
-11
test/env-mixed/fixtures/project/test/jsdom.test.ts
··· 1 - /** 2 - * @vitest-environment jsdom 3 - */ 4 - 5 - import { expect, test } from 'vitest' 6 - 7 - test('Leaking globals not found', async () => { 8 - (globalThis as any).__leaking_from_jsdom = 'leaking' 9 - expect((globalThis as any).__leaking_from_node).toBe(undefined) 10 - expect((globalThis as any).__leaking_from_happy_dom).toBe(undefined) 11 - })
-11
test/env-mixed/fixtures/project/test/node.test.ts
··· 1 - /** 2 - * @vitest-environment node 3 - */ 4 - 5 - import { expect, test } from 'vitest' 6 - 7 - test('Leaking globals not found', async () => { 8 - (globalThis as any).__leaking_from_node = 'leaking' 9 - expect((globalThis as any).__leaking_from_jsdom).toBe(undefined) 10 - expect((globalThis as any).__leaking_from_happy_dom).toBe(undefined) 11 - })
-7
test/env-mixed/fixtures/project/test/workspace-project.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('Leaking globals not found', async () => { 4 - expect((globalThis as any).__leaking_from_workspace_project).toBe(undefined) 5 - 6 - ;(globalThis as any).__leaking_from_workspace_project = 'leaking' 7 - })
-3
test/filters/fixtures-slash/test/basic-foo/a.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test('example', () => {})
-3
test/filters/fixtures-slash/test/basic/a.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test('example', () => {})
-3
test/filters/fixtures-slash/test/foo-basic/a.test.ts
··· 1 - import { test } from 'vitest' 2 - 3 - test('example', () => {})
-8
test/snapshots/test/fixtures/basic/input.json
··· 1 - [ 2 - [ 3 - ".name", 4 - { 5 - "color": "red" 6 - } 7 - ] 8 - ]
-3
test/snapshots/test/fixtures/basic/output.css
··· 1 - .name { 2 - color: red; 3 - }
-15
test/snapshots/test/fixtures/multiple/input.json
··· 1 - [ 2 - [ 3 - ".text-red", 4 - { 5 - "color": "red" 6 - } 7 - ], 8 - [ 9 - ".text-lg", 10 - { 11 - "font-size": "1.25rem", 12 - "line-height": "1.75rem" 13 - } 14 - ] 15 - ]
-7
test/snapshots/test/fixtures/multiple/output.css
··· 1 - .text-red { 2 - color: red; 3 - } 4 - .text-lg { 5 - font-size: 1.25rem; 6 - line-height: 1.75rem; 7 - }
-4
test/vite-node/deps/dep1/esm/index.js
··· 1 - // esm/index.js was detected as isValidNodeImport(id) = false 2 - // event if package.json has type = module, 3 - // which causes dual package hazard when other external esm import esm/index.js. 4 - export const data = {}
test/vm-threads/src/external/assets/file1.png
test/vm-threads/src/external/assets/file2.txt
test/vm-threads/src/external/assets/file3.svg
-3
test/vm-threads/src/external/css/empty.css
··· 1 - .test1 { 2 - color: red; 3 - }
-3
test/vm-threads/src/external/css/processed.css
··· 1 - .test2 { 2 - color: green; 3 - }
-3
test/vm-threads/src/external/css/processed.module.css
··· 1 - .test3 { 2 - color: yellow; 3 - }
-1
test/vm-threads/src/external/package-null/package-null.js
··· 1 - module.exports = 42
-3
test/changed/fixtures/workspace/packages/packageA/index.js
··· 1 - export default function getLetter() { 2 - return 'c'; 3 - }
-8
test/changed/fixtures/workspace/packages/packageA/index.test.js
··· 1 - import { describe, expect, it } from 'vitest'; 2 - import getLetter from './index'; 3 - describe('getLetter', () => { 4 - const result = getLetter(); 5 - it('should return c', () => { 6 - expect(result).toBe('c'); 7 - }); 8 - });
-3
test/changed/fixtures/workspace/packages/packageA/vitest.config.mjs
··· 1 - import { defineConfig } from "vitest/config"; 2 - 3 - export default defineConfig({});
-3
test/changed/fixtures/workspace/packages/packageB/index.js
··· 1 - export default function getNumber() { 2 - return 3; 3 - }
-8
test/changed/fixtures/workspace/packages/packageB/index.test.js
··· 1 - import { describe, expect, it } from 'vitest'; 2 - import getNumber from './index'; 3 - describe('getNumber', () => { 4 - const result = getNumber(); 5 - it('should return 3', () => { 6 - expect(result).toBe(3); 7 - }); 8 - });
-3
test/changed/fixtures/workspace/packages/packageB/vitest.config.mjs
··· 1 - import { defineConfig } from "vitest/config"; 2 - 3 - export default defineConfig({});
+1
test/cli/fixtures/git-changed/related/src/sourceA.ts
··· 1 + export const A = 'A'
+1
test/cli/fixtures/git-changed/related/src/sourceB.ts
··· 1 + export const B = 'B'
+2
test/cli/fixtures/git-changed/related/src/sourceC.ts
··· 1 + // re-exporting for deep changed detection 2 + export { A } from './sourceA'
+4
test/cli/fixtures/git-changed/related/src/sourceD.ts
··· 1 + // import and re-exporting for deep changed detection 2 + import { A as sourceA } from './sourceA' 3 + 4 + export const A = sourceA
-5
test/cli/fixtures/project/packages/project_1/base.test.ts
··· 1 - import { expect, test } from "vitest"; 2 - 3 - test("", () => { 4 - expect(1).toBe(1); 5 - })
-5
test/cli/fixtures/project/packages/project_2/base.test.ts
··· 1 - import { expect, test } from "vitest"; 2 - 3 - test("", () => { 4 - expect(1).toBe(1); 5 - })
-5
test/cli/fixtures/project/packages/space_1/base.test.ts
··· 1 - import { expect, test } from "vitest"; 2 - 3 - test("", () => { 4 - expect(1).toBe(1); 5 - })
+7
test/cli/fixtures/vm-threads/src/external/default-cjs.cjs
··· 1 + module.exports = { 2 + a: 'a', 3 + b: 'b', 4 + object: { 5 + h: 'h', 6 + }, 7 + }
+2
test/cli/fixtures/vm-threads/src/external/export-default-cjs.js
··· 1 + export * from './default-cjs.cjs' 2 + export { default } from './default-cjs.cjs'
+2
test/cli/fixtures/vm-threads/src/external/export-nested-default-cjs.js
··· 1 + export * from './nested-default-cjs.cjs' 2 + export { default } from './nested-default-cjs.cjs'
+8
test/cli/fixtures/vm-threads/src/external/nested-default-cjs.cjs
··· 1 + exports.default = { 2 + a: 'a', 3 + b: 'b', 4 + object: { 5 + h: 'h', 6 + }, 7 + } 8 + Object.defineProperty(exports, '__esModule', { value: true, enumerable: false })
+15
test/cli/fixtures/vm-threads/src/external/not-found.js
··· 1 + export async function importPackage() { 2 + await import('@vitest/non-existing-package') 3 + } 4 + 5 + export async function importPath() { 6 + await import('./non-existing-path') 7 + } 8 + 9 + export async function importBuiltin() { 10 + await import('node:non-existing-builtin') 11 + } 12 + 13 + export async function importNamespace() { 14 + await import('non-existing-namespace:xyz') 15 + }
+3
test/cli/fixtures/vm-threads/src/external/package.json
··· 1 + { 2 + "type": "module" 3 + }
+1
test/cli/fixtures/vm-threads/src/external/primitive-cjs.cjs
··· 1 + module.exports = 'string'
+3
test/config/fixtures/filters-slash/test/basic-foo/a.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test('example', () => {})
+3
test/config/fixtures/filters-slash/test/basic/a.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test('example', () => {})
+3
test/config/fixtures/filters-slash/test/foo-basic/a.test.ts
··· 1 + import { test } from 'vitest' 2 + 3 + test('example', () => {})
+11
test/config/fixtures/mixed-environments/project/test/happy-dom.test.ts
··· 1 + /** 2 + * @vitest-environment happy-dom 3 + */ 4 + 5 + import { expect, test } from 'vitest' 6 + 7 + test('Leaking globals not found', async () => { 8 + (globalThis as any).__leaking_from_happy_dom = 'leaking' 9 + expect((globalThis as any).__leaking_from_node).toBe(undefined) 10 + expect((globalThis as any).__leaking_from_jsdom).toBe(undefined) 11 + })
+11
test/config/fixtures/mixed-environments/project/test/jsdom.test.ts
··· 1 + /** 2 + * @vitest-environment jsdom 3 + */ 4 + 5 + import { expect, test } from 'vitest' 6 + 7 + test('Leaking globals not found', async () => { 8 + (globalThis as any).__leaking_from_jsdom = 'leaking' 9 + expect((globalThis as any).__leaking_from_node).toBe(undefined) 10 + expect((globalThis as any).__leaking_from_happy_dom).toBe(undefined) 11 + })
+11
test/config/fixtures/mixed-environments/project/test/node.test.ts
··· 1 + /** 2 + * @vitest-environment node 3 + */ 4 + 5 + import { expect, test } from 'vitest' 6 + 7 + test('Leaking globals not found', async () => { 8 + (globalThis as any).__leaking_from_node = 'leaking' 9 + expect((globalThis as any).__leaking_from_jsdom).toBe(undefined) 10 + expect((globalThis as any).__leaking_from_happy_dom).toBe(undefined) 11 + })
+7
test/config/fixtures/mixed-environments/project/test/workspace-project.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('Leaking globals not found', async () => { 4 + expect((globalThis as any).__leaking_from_workspace_project).toBe(undefined) 5 + 6 + ;(globalThis as any).__leaking_from_workspace_project = 'leaking' 7 + })
+5
test/config/fixtures/project/packages/project_1/base.test.ts
··· 1 + import { expect, test } from "vitest"; 2 + 3 + test("", () => { 4 + expect(1).toBe(1); 5 + })
+5
test/config/fixtures/project/packages/project_2/base.test.ts
··· 1 + import { expect, test } from "vitest"; 2 + 3 + test("", () => { 4 + expect(1).toBe(1); 5 + })
+5
test/config/fixtures/project/packages/space_1/base.test.ts
··· 1 + import { expect, test } from "vitest"; 2 + 3 + test("", () => { 4 + expect(1).toBe(1); 5 + })
+8
test/core/test/fixtures/snapshots/basic/input.json
··· 1 + [ 2 + [ 3 + ".name", 4 + { 5 + "color": "red" 6 + } 7 + ] 8 + ]
+3
test/core/test/fixtures/snapshots/basic/output.css
··· 1 + .name { 2 + color: red; 3 + }
+15
test/core/test/fixtures/snapshots/multiple/input.json
··· 1 + [ 2 + [ 3 + ".text-red", 4 + { 5 + "color": "red" 6 + } 7 + ], 8 + [ 9 + ".text-lg", 10 + { 11 + "font-size": "1.25rem", 12 + "line-height": "1.75rem" 13 + } 14 + ] 15 + ]
+7
test/core/test/fixtures/snapshots/multiple/output.css
··· 1 + .text-red { 2 + color: red; 3 + } 4 + .text-lg { 5 + font-size: 1.25rem; 6 + line-height: 1.75rem; 7 + }
-5
test/cwd/.cache/projects/test/.cache/should-not-run.test.ts
··· 1 - import { expect, test } from 'vitest' 2 - 3 - test('should not run', () => { 4 - expect(1).toBe(2) 5 - })
+5
test/cli/fixtures/dotted-files/.cache/projects/test/should-run.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('should run', () => { 4 + expect(1).toBe(1) 5 + })
+3
test/cli/fixtures/git-changed/workspace/packages/packageA/index.js
··· 1 + export default function getLetter() { 2 + return 'c'; 3 + }
+8
test/cli/fixtures/git-changed/workspace/packages/packageA/index.test.js
··· 1 + import { describe, expect, it } from 'vitest'; 2 + import getLetter from './index'; 3 + describe('getLetter', () => { 4 + const result = getLetter(); 5 + it('should return c', () => { 6 + expect(result).toBe('c'); 7 + }); 8 + });
+3
test/cli/fixtures/git-changed/workspace/packages/packageA/vitest.config.mjs
··· 1 + import { defineConfig } from "vitest/config"; 2 + 3 + export default defineConfig({});
+3
test/cli/fixtures/git-changed/workspace/packages/packageB/index.js
··· 1 + export default function getNumber() { 2 + return 3; 3 + }
+8
test/cli/fixtures/git-changed/workspace/packages/packageB/index.test.js
··· 1 + import { describe, expect, it } from 'vitest'; 2 + import getNumber from './index'; 3 + describe('getNumber', () => { 4 + const result = getNumber(); 5 + it('should return 3', () => { 6 + expect(result).toBe(3); 7 + }); 8 + });
+3
test/cli/fixtures/git-changed/workspace/packages/packageB/vitest.config.mjs
··· 1 + import { defineConfig } from "vitest/config"; 2 + 3 + export default defineConfig({});
test/cli/fixtures/vm-threads/src/external/assets/file1.png
test/cli/fixtures/vm-threads/src/external/assets/file2.txt
test/cli/fixtures/vm-threads/src/external/assets/file3.svg
+3
test/cli/fixtures/vm-threads/src/external/css/empty.css
··· 1 + .test1 { 2 + color: red; 3 + }
+3
test/cli/fixtures/vm-threads/src/external/css/processed.css
··· 1 + .test2 { 2 + color: green; 3 + }
+3
test/cli/fixtures/vm-threads/src/external/css/processed.module.css
··· 1 + .test3 { 2 + color: yellow; 3 + }
+1
test/cli/fixtures/vm-threads/src/external/package-null/package-null.js
··· 1 + module.exports = 42
+5
test/cli/fixtures/dotted-files/.cache/projects/test/.cache/should-not-run.test.ts
··· 1 + import { expect, test } from 'vitest' 2 + 3 + test('should not run', () => { 4 + expect(1).toBe(2) 5 + })