= {
};
// todo: is there a better way to do this?
-jest.mock(`../../src/transformers/babel`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/babel`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
-jest.mock(`../../src/transformers/typescript`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/typescript`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
-jest.mock(`../../src/transformers/coffeescript`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/coffeescript`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
-jest.mock(`../../src/transformers/scss`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/scss`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
-jest.mock(`../../src/transformers/less`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/less`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
-jest.mock(`../../src/transformers/stylus`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/stylus`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
-jest.mock(`../../src/transformers/postcss`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/postcss`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
-jest.mock(`../../src/transformers/globalStyle`, () => ({
- transformer: jest.fn(() => ({ code: '' })),
+vi.mock(`../../src/transformers/globalStyle`, () => ({
+ transformer: vi.fn(() => ({ code: '' })),
}));
afterAll(() => {
- jest.resetAllMocks();
+ vi.resetAllMocks();
});
describe(`sourcemap generation`, () => {
diff --git a/test/autoProcess/style.test.ts b/test/autoProcess/style.test.ts
index e3843e21..ad9cd9fb 100644
--- a/test/autoProcess/style.test.ts
+++ b/test/autoProcess/style.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import sveltePreprocess from '../../src';
import { preprocess, getFixtureContent, CSS_PATTERN } from '../utils';
diff --git a/test/modules/globalifySelector.test.ts b/test/modules/globalifySelector.test.ts
index cddbe7f8..6d964dd7 100644
--- a/test/modules/globalifySelector.test.ts
+++ b/test/modules/globalifySelector.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { globalifySelector } from '../../src/modules/globalifySelector';
describe('globalifySelector', () => {
@@ -57,4 +58,10 @@ describe('globalifySelector', () => {
`:global(p:nth-child(n+8):nth-child(-n+15))`,
);
});
+
+ it('works with selector with whitespace in parenthesis: :is()', async () => {
+ expect(globalifySelector('article :is(h1, h2)')).toBe(
+ `:global(article) :global(:is(h1, h2))`,
+ );
+ });
});
diff --git a/test/modules/modules.test.ts b/test/modules/modules.test.ts
index a4b799f7..2490d3d0 100644
--- a/test/modules/modules.test.ts
+++ b/test/modules/modules.test.ts
@@ -1,5 +1,5 @@
import { resolve } from 'path';
-
+import { describe, it, expect } from 'vitest';
import { getTestAppFilename, getFixtureContent } from '../utils';
import { getTagInfo } from '../../src/modules/tagInfo';
import { getIncludePaths, hasDepInstalled } from '../../src/modules/utils';
diff --git a/test/processors/babel.test.ts b/test/processors/babel.test.ts
index af69eb52..4e31ca5f 100644
--- a/test/processors/babel.test.ts
+++ b/test/processors/babel.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { babel } from '../../src';
import { preprocess } from '../utils';
@@ -22,7 +23,7 @@ describe(`processor - babel`, () => {
]);
expect(preprocessed.toString?.()).toMatchInlineSnapshot(`
- ""
`);
});
diff --git a/test/processors/coffeescript.test.ts b/test/processors/coffeescript.test.ts
index d5099798..cda2cda0 100644
--- a/test/processors/coffeescript.test.ts
+++ b/test/processors/coffeescript.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { coffeescript } from '../../src';
import { getFixtureContent, preprocess } from '../utils';
diff --git a/test/processors/less.test.ts b/test/processors/less.test.ts
index 46d077a4..776aabbc 100644
--- a/test/processors/less.test.ts
+++ b/test/processors/less.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { less } from '../../src';
import { CSS_PATTERN, preprocess } from '../utils';
diff --git a/test/processors/postcss.test.ts b/test/processors/postcss.test.ts
index b460b903..a08a06ad 100644
--- a/test/processors/postcss.test.ts
+++ b/test/processors/postcss.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { postcss } from '../../src';
import { CSS_PATTERN, preprocess, spyConsole } from '../utils';
diff --git a/test/processors/pug.test.ts b/test/processors/pug.test.ts
index 762c3ab4..cff6a19e 100644
--- a/test/processors/pug.test.ts
+++ b/test/processors/pug.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { pug } from '../../src';
import { getFixtureContent, preprocess } from '../utils';
diff --git a/test/processors/scss.test.ts b/test/processors/scss.test.ts
index f69d8654..79d5bed8 100644
--- a/test/processors/scss.test.ts
+++ b/test/processors/scss.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { scss, sass } from '../../src';
import { CSS_PATTERN, preprocess } from '../utils';
diff --git a/test/processors/stylus.test.ts b/test/processors/stylus.test.ts
index 81787859..a19f5719 100644
--- a/test/processors/stylus.test.ts
+++ b/test/processors/stylus.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { stylus } from '../../src';
import { CSS_PATTERN, preprocess } from '../utils';
diff --git a/test/processors/typescript.test.ts b/test/processors/typescript.test.ts
index ca485989..f97a3e22 100644
--- a/test/processors/typescript.test.ts
+++ b/test/processors/typescript.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import { typescript } from '../../src';
import { getFixtureContent, preprocess } from '../utils';
diff --git a/test/transformers/babel.test.ts b/test/transformers/babel.test.ts
index f3f02c0d..133efcb2 100644
--- a/test/transformers/babel.test.ts
+++ b/test/transformers/babel.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import sveltePreprocess from '../../src';
import { preprocess } from '../utils';
@@ -16,8 +17,8 @@ const BABEL_CONFIG = {
],
};
-beforeAll(() => jest.setTimeout(10000));
-afterAll(() => jest.setTimeout(5000));
+// beforeAll(() => jest.setTimeout(10000));
+// afterAll(() => jest.setTimeout(5000));
describe('transformer - babel', () => {
it('transpiles with babel', async () => {
diff --git a/test/transformers/globalStyle.test.ts b/test/transformers/globalStyle.test.ts
index 3a8b2201..651ff62f 100644
--- a/test/transformers/globalStyle.test.ts
+++ b/test/transformers/globalStyle.test.ts
@@ -1,3 +1,4 @@
+import { describe, it, expect } from 'vitest';
import autoProcess from '../../src';
import { preprocess } from '../utils';
diff --git a/test/transformers/less.test.ts b/test/transformers/less.test.ts
index 581e83ea..5e5a3810 100644
--- a/test/transformers/less.test.ts
+++ b/test/transformers/less.test.ts
@@ -1,5 +1,5 @@
import { resolve } from 'path';
-
+import { describe, it, expect } from 'vitest';
import sveltePreprocess from '../../src';
import { preprocess } from '../utils';
diff --git a/test/transformers/postcss.test.ts b/test/transformers/postcss.test.ts
index 7718bd33..c9af99df 100644
--- a/test/transformers/postcss.test.ts
+++ b/test/transformers/postcss.test.ts
@@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports */
import { resolve } from 'path';
-
+import { test, expect, vi } from 'vitest';
import sveltePreprocess from '../../src';
import { preprocess, spyConsole } from '../utils';
import { transformer } from '../../src/transformers/postcss';
@@ -143,7 +143,7 @@ test('automatically removes indentation for lang=sugarss', async () => {
const preprocessed = await preprocess(template, opts);
expect(preprocessed.toString?.()).toMatchInlineSnapshot(`
- ""
@@ -151,8 +151,8 @@ test('automatically removes indentation for lang=sugarss', async () => {
});
test('should not override postcss with custom style language', async () => {
- const custom = jest.fn(({ content }) => ({ code: content }));
- const postcss = jest.fn(({ content }) => ({ code: content }));
+ const custom = vi.fn(({ content }) => ({ code: content }));
+ const postcss = vi.fn(({ content }) => ({ code: content }));
const opts = sveltePreprocess({ custom, postcss });
await preprocess(
@@ -165,8 +165,8 @@ test('should not override postcss with custom style language', async () => {
});
test('should execute postcss alias override before postcss', async () => {
- const sugarss = jest.fn(({ content }) => ({ code: content }));
- const postcss = jest.fn(({ content }) => ({ code: content }));
+ const sugarss = vi.fn(({ content }) => ({ code: content }));
+ const postcss = vi.fn(({ content }) => ({ code: content }));
const opts = sveltePreprocess({ sugarss, postcss });
await preprocess(
diff --git a/test/transformers/pug.test.ts b/test/transformers/pug.test.ts
index 11aae511..c08e1898 100644
--- a/test/transformers/pug.test.ts
+++ b/test/transformers/pug.test.ts
@@ -1,5 +1,5 @@
import { resolve } from 'path';
-
+import { describe, it, expect } from 'vitest';
import sveltePreprocess from '../../src';
import { preprocess } from '../utils';
diff --git a/test/transformers/replace.test.ts b/test/transformers/replace.test.ts
index 14b1bec6..58b20119 100644
--- a/test/transformers/replace.test.ts
+++ b/test/transformers/replace.test.ts
@@ -1,6 +1,6 @@
import autoProcess from '../../src';
import { preprocess } from '../utils';
-
+import { describe, it, expect } from 'vitest';
import type { Options } from '../../src/types';
const options: Options.Replace = [
@@ -132,7 +132,7 @@ describe('transformer - regex', () => {
expect(preprocessed.toString?.()).toMatchInlineSnapshot(`
""
`);
});
diff --git a/test/transformers/scss.test.ts b/test/transformers/scss.test.ts
index a5ccc66a..9ab52835 100644
--- a/test/transformers/scss.test.ts
+++ b/test/transformers/scss.test.ts
@@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import { resolve } from 'path';
-
+import { describe, it, expect } from 'vitest';
import sveltePreprocess from '../../src';
import { preprocess } from '../utils';
import { transformer } from '../../src/transformers/scss';
@@ -50,7 +50,7 @@ describe('transformer - scss', () => {
const preprocessed = await preprocess(template, opts);
expect(preprocessed.toString?.()).toMatchInlineSnapshot(`
- ""
`);
diff --git a/test/transformers/stylus.test.ts b/test/transformers/stylus.test.ts
index 9b7a279d..21287853 100644
--- a/test/transformers/stylus.test.ts
+++ b/test/transformers/stylus.test.ts
@@ -1,5 +1,5 @@
import { resolve } from 'path';
-
+import { describe, it, expect } from 'vitest';
import sveltePreprocess from '../../src';
import { preprocess } from '../utils';
diff --git a/test/transformers/typescript.test.ts b/test/transformers/typescript.test.ts
index 3d57f4c6..59d71178 100644
--- a/test/transformers/typescript.test.ts
+++ b/test/transformers/typescript.test.ts
@@ -1,7 +1,6 @@
import { resolve } from 'path';
-
-import { compile, VERSION } from 'svelte/compiler';
-
+import { compile } from 'svelte/compiler';
+import { describe, it, expect } from 'vitest';
import sveltePreprocess from '../../src';
import { loadTsconfig } from '../../src/transformers/typescript';
import {
@@ -10,14 +9,11 @@ import {
spyConsole,
getTestAppFilename,
} from '../utils';
-
import type { Processed } from '../../src/types';
import type { Diagnostic } from 'typescript';
spyConsole({ silent: true });
-const IS_SVELTE_5_PLUS = Number(VERSION.split('.')[0]) >= 5;
-
const EXPECTED_SCRIPT = getFixtureContent('script.js');
const autoProcessTS = (content: string, compilerOptions?: any) => {
@@ -133,26 +129,6 @@ describe('transformer - typescript', () => {
expect(code).not.toContain("'./type'");
});
- it('should keep all value imports with (deprecated) preserveValueImports and auto-adds ignoreDeprecations flag', async () => {
- const tpl = getFixtureContent('PreserveValueImports.svelte');
-
- const opts = sveltePreprocess({
- typescript: {
- tsconfigFile: false,
- compilerOptions: {
- preserveValueImports: true,
- },
- },
- });
-
- const { code } = await preprocess(tpl, opts);
-
- expect(code).toContain("import { Bar } from './somewhere'");
- expect(code).toContain("import Component from './component.svelte'");
- expect(code).toContain("import { Value } from './value'");
- expect(code).not.toContain("'./type'");
- });
-
it('should deal with empty transpilation result', async () => {
const tpl = getFixtureContent('TypeScriptTypesOnly.svelte');
@@ -228,60 +204,4 @@ describe('transformer - typescript', () => {
expect(code).not.toContain('||=');
});
});
-
- (IS_SVELTE_5_PLUS ? describe.skip : describe)('mixed imports', () => {
- it('should strip unused and type imports', async () => {
- const tpl = getFixtureContent('TypeScriptImports.svelte');
-
- const opts = sveltePreprocess({
- typescript: { tsconfigFile: false },
- });
-
- const { code } = await preprocess(tpl, opts);
-
- // Test that imports are properly preserved
- expect(code).toContain(`import { fly } from "svelte/transition"`);
- expect(code).toContain(`import { flip } from "svelte/animate"`);
- expect(code).toContain(`import Nested from "./Nested.svelte"`);
- expect(code).toContain(`import { hello } from "./script"`);
- expect(code).toContain(`import { AValue } from "./types"`);
- expect(code).toContain(
- `import { storeTemplateOnly, storeScriptOnly, store0 } from "./store"`,
- );
- expect(code).toContain(
- `import { onlyUsedInModuleScript } from "./modulescript";`,
- );
- expect(code).toContain(
- `import { storeModuleTemplateOnly, storeModuleScriptOnly } from "./store";`,
- );
- // Test that comments are properly preserved
- expect(code).toContain('');
- });
-
- it('should strip unused and type imports in context="module" tags', async () => {
- const tpl = getFixtureContent('TypeScriptImportsModule.svelte');
-
- const opts = sveltePreprocess({
- typescript: { tsconfigFile: false },
- });
-
- const { code } = await preprocess(tpl, opts);
-
- expect(code).toContain(`import { AValue } from "./types";`);
- });
-
- it('should work when tsconfig contains outDir', async () => {
- const opts = sveltePreprocess({
- typescript: {
- tsconfigFile: './test/fixtures/tsconfig.outdir.json',
- handleMixedImports: true,
- },
- sourceMap: true,
- });
-
- const preprocessed = await preprocess(template, opts);
-
- expect(preprocessed.toString?.()).toContain(EXPECTED_SCRIPT);
- });
- });
});
diff --git a/test/utils.ts b/test/utils.ts
index 37bf3ffe..03a99c45 100644
--- a/test/utils.ts
+++ b/test/utils.ts
@@ -1,5 +1,6 @@
import { readFileSync } from 'fs';
import { resolve } from 'path';
+import { vi, afterAll, afterEach } from 'vitest';
import {
compile as svelteCompile,
@@ -42,9 +43,9 @@ export const getFixtureContent = (file: string) =>
readFileSync(exports.getFixturePath(file)).toString().trim();
export function spyConsole({ silent = true } = {}) {
- const warnSpy = jest.spyOn(global.console, 'warn');
- const errorSpy = jest.spyOn(global.console, 'error');
- const logSpy = jest.spyOn(global.console, 'log');
+ const warnSpy = vi.spyOn(global.console, 'warn');
+ const errorSpy = vi.spyOn(global.console, 'error');
+ const logSpy = vi.spyOn(global.console, 'log');
if (silent) {
warnSpy.mockImplementation(() => {});
diff --git a/tsconfig.json b/tsconfig.json
index 6015450f..026128f7 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -9,8 +9,8 @@
"lib": ["es2018"],
"declaration": true,
"skipLibCheck": true,
- "types": ["jest", "node"],
- "outDir": "dist",
+ "types": ["node"],
+ "outDir": "dist"
},
"include": ["**/*.ts"],
"exclude": ["node_modules/**/*", "dist", "examples"]
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy