Skip to content

Commit

Permalink
chore(tests): disable usage of vitest globals (#4740)
Browse files Browse the repository at this point in the history
  • Loading branch information
cardoso authored Oct 31, 2024
1 parent 0343d05 commit 6f00341
Show file tree
Hide file tree
Showing 60 changed files with 76 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'node:path';
import { describe } from 'vitest';
import { transformSync } from '@babel/core';
import { LWC_VERSION, HIGHEST_API_VERSION } from '@lwc/shared';
import { testFixtureDir } from '@lwc/test-utils-lwc-internals';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, expect, it } from 'vitest';
import { TransformOptions } from '../../options';
import { transform } from '../transformer';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { vi } from 'vitest';
import { vi, describe, it, expect } from 'vitest';
import { APIVersion, noop } from '@lwc/shared';
import { TransformOptions } from '../../options';
import { transformSync } from '../transformer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { vi } from 'vitest';
import { vi, describe, it, expect } from 'vitest';
import { noop } from '@lwc/shared';
import { TransformOptions } from '../../options';
import { transform, transformSync } from '../transformer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import { transform, transformSync } from '../../transformers/transformer';

function testValidateOptions(methodName: string, method: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import { ReactiveObserver, valueMutated, valueObserved } from '../index';

describe('reactive-service', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import {
createElement,
LightningElement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import { createElement } from '../index';

describe('createElement', () => {
Expand Down
7 changes: 3 additions & 4 deletions packages/@lwc/engine-server/src/__tests__/fixtures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import path from 'path';

import path from 'node:path';
import { vi, describe } from 'vitest';
import { rollup } from 'rollup';
import lwcRollupPlugin from '@lwc/rollup-plugin';
import { vi } from 'vitest';
import { testFixtureDir, formatHTML } from '@lwc/test-utils-lwc-internals';
import type * as lwc from '../index';

Expand Down Expand Up @@ -42,7 +41,7 @@ async function compileFixture({ input, dirname }: { input: string; dirname: stri

const bundle = await rollup({
input,
external: ['lwc'],
external: ['lwc', 'vitest'],
plugins: [
lwcRollupPlugin({
enableDynamicComponents: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'vitest';
import { LightningElement } from 'lwc';

export default class GetterClassListNoop extends LightningElement{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'vitest';
import { LightningElement } from 'lwc';

export default class GetterClassList extends LightningElement{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'vitest';
import { LightningElement } from 'lwc';

export default class MethodsNoop extends LightningElement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'vitest';
import { LightningElement } from 'lwc';

export default class MethodsUnsupported extends LightningElement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import path from 'path';
import vm from 'vm';
import path from 'node:path';
import vm from 'node:vm';
import { vi, describe, it, expect } from 'vitest';
import { parseFragment, serialize } from 'parse5';
import { rollup, RollupLog } from 'rollup';
import replace from '@rollup/plugin-replace';
import virtual from '@rollup/plugin-virtual';
import lwcRollupPlugin from '@lwc/rollup-plugin';
import { vi } from 'vitest';
import * as engineServer from '../index';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import { renderComponent, LightningElement } from '../index';

class Test extends LightningElement {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { it, expect } from 'vitest';
import { swapComponent, swapStyle, swapTemplate } from '../index';

it('throws error for swapComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import { validateStyleTextContents } from '../utils/validate-style-text-contents';

// See https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
Expand Down
6 changes: 3 additions & 3 deletions packages/@lwc/errors/src/__tests__/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import 'vitest';
import path from 'path';
import fs from 'fs';
import path from 'node:path';
import fs from 'node:fs';
import { describe, it, expect } from 'vitest';
import { hasOwnProperty } from '@lwc/shared';
import * as CompilerErrors from '../compiler/error-info';
import { LWCErrorInfo } from '../shared/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import {
CompilerError,
generateCompilerError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, expect, it } from 'vitest';
import * as errorInfo from '../error-info';
// All exported objects are maps of label/error info, except for GENERIC_COMPILER_ERROR,
// which is a top-level error info object
Expand Down
1 change: 1 addition & 0 deletions packages/@lwc/features/src/__tests__/features.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import { describe, it, expect } from 'vitest';
import features from '../index';

describe('features', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import { describe, it, expect } from 'vitest';
import { lwcRuntimeFlags } from '../index';

describe('lwcRuntimeFlags', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import { MockInstance, vi } from 'vitest';
import { vi, describe, afterEach, beforeEach, expect, it, type MockInstance } from 'vitest';
import { lwcRuntimeFlags, setFeatureFlag } from '../index';

describe('setFeatureFlag', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/@lwc/module-resolver/scripts/test/setup-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import { expect } from 'vitest';
import { toThrowErrorWithType } from './matchers/to-throw-error-with-type';
import { toThrowErrorWithCode } from './matchers/to-throw-error-with-code';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import { describe, test, expect } from 'vitest';
import '../../scripts/test/types';
import { resolveModule } from '../index';
import { RegistryType } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, test, expect } from 'vitest';
import '../../scripts/test/types';
import { resolveModule } from '../index';
import { fixture, NO_LWC_MODULE_FOUND_CODE, LWC_CONFIG_ERROR_CODE } from './test-utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, test, expect } from 'vitest';
import '../../scripts/test/types';
import { resolveModule } from '../index';
import { RegistryType } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, test, expect } from 'vitest';
import '../../scripts/test/types';
import { resolveModule } from '../index';
import { RegistryType } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'node:path';
import { describe, it, expect } from 'vitest';
import { rollup, RollupLog } from 'rollup';
import { APIVersion, HIGHEST_API_VERSION, LOWEST_API_VERSION } from '@lwc/shared';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'path';
import path from 'node:path';
import { describe, it, expect } from 'vitest';
import { rollup, type RollupLog, type RollupBuild } from 'rollup';

import lwc, { type RollupLwcOptions } from '../../index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'node:path';
import { describe, it, expect } from 'vitest';
import { rollup, RollupLog } from 'rollup';
import lwc, { RollupLwcOptions } from '../../index';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'path';
import path from 'node:path';
import { describe, it, expect } from 'vitest';
import { rollup } from 'rollup';

import lwc from '../../index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'path';
import fs from 'fs';
import path from 'node:path';
import fs from 'node:fs';
import { describe, it, expect } from 'vitest';
import { rollup, type RollupLog, type Plugin, type RollupBuild } from 'rollup';
import nodeResolve from '@rollup/plugin-node-resolve';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'path';
import { rollup } from 'rollup';
import path from 'node:path';
import { describe, it, expect } from 'vitest';

import { rollup, type RollupLog } from 'rollup';
import lwc from '../../index';

describe('rootDir', () => {
Expand Down Expand Up @@ -35,7 +36,7 @@ describe('rootDir', () => {
});

it('warns if an "input" object is passed and when "rootDir" is not set', async () => {
const warnings: any = [];
const warnings: RollupLog[] = [];

await rollup({
input: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import path from 'path';
import path from 'node:path';
import { describe, it, expect } from 'vitest';
import { rollup, RollupLog } from 'rollup';
import { APIVersion } from '@lwc/shared';
import lwc from '../../index';
Expand Down
1 change: 1 addition & 0 deletions packages/@lwc/shared/src/__tests__/assert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, it, expect } from 'vitest';
import { assert } from '../index';

describe('assert', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/@lwc/shared/src/__tests__/html-attributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { describe, test, expect } from 'vitest';
import { htmlPropertyToAttribute, kebabCaseToCamelCase } from '../html-attributes';

type StringPair = [prop: string, attr: string];
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/shared/src/__tests__/signals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
import { vi } from 'vitest';
import { describe, beforeEach, expect, it, vi } from 'vitest';

describe('signals', () => {
let setTrustedSignalSet: (signals: WeakSet<object>) => void;
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/signals/src/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

import { vi } from 'vitest';
import { vi, describe, it, expect } from 'vitest';
import { Signal } from './signal';

describe('signal protocol', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import { describe, test, expect } from 'vitest';
import { compileComponentForSSR } from '../index';

describe('component compilation', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/@lwc/ssr-compiler/src/__tests__/estemplate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { is, builders as b } from 'estree-toolkit';
import { describe, test, expect } from 'vitest';
import { esTemplate, esTemplateWithYield } from '../estemplate';

describe.each(
Expand Down Expand Up @@ -54,7 +55,7 @@ describe.each(
const tmpl = topLevelFn`
const ${is.identifier} = 'foo';
`;
const doReplacement = () => tmpl(b.literal('I am not an identifier'));
const doReplacement = () => tmpl(b.literal('I am not an identifier') as any);
expect(doReplacement).toThrow(
'Validation failed for templated node of type Identifier'
);
Expand Down
2 changes: 1 addition & 1 deletion packages/@lwc/ssr-compiler/src/__tests__/fixtures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import path from 'node:path';
import { vi } from 'vitest';
import { vi, describe } from 'vitest';
import { rollup, RollupLog } from 'rollup';
import lwcRollupPlugin from '@lwc/rollup-plugin';
import { FeatureFlagName } from '@lwc/features/dist/types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseModule } from 'meriyah';
import { generate } from 'astring';
import { beforeAll } from 'vitest';
import { describe, beforeAll, test, expect } from 'vitest';
import { transmogrify } from '../transmogrify';
import type { Program as EsProgram } from 'estree';

Expand Down
Loading

0 comments on commit 6f00341

Please sign in to comment.