Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { rollup } from 'rollup';
import lwcRollupPlugin from '@lwc/rollup-plugin';

Expand All @@ -9,6 +10,8 @@ import {
DISABLE_SYNTHETIC_SHADOW_SUPPORT_IN_COMPILER,
} from '../../helpers/options.js';

const UTILS = fileURLToPath(new URL('../../helpers/utils.js', import.meta.url));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only real change. Everything else is just changes to imports.


/** Cache reused between each compilation to speed up the compilation time. */
let cache;

Expand All @@ -22,7 +25,7 @@ const createRollupPlugin = (input, options) => {
// Sourcemaps don't work with Istanbul coverage
sourcemap: !process.env.COVERAGE,
experimentalDynamicComponent: {
loader: 'test-utils',
loader: UTILS,
strict: true,
},
enableDynamicComponents: true,
Expand Down Expand Up @@ -85,7 +88,7 @@ const transform = async (ctx) => {

// Rollup should not attempt to resolve the engine and the test utils, Karma takes care of injecting it
// globally in the page before running the tests.
external: ['lwc', 'wire-service', 'test-utils', '@test/loader'],
external: ['lwc', 'wire-service', '@test/loader', UTILS],

onwarn(warning, warn) {
// Ignore warnings from our own Rollup plugin
Expand Down
8 changes: 4 additions & 4 deletions packages/@lwc/integration-not-karma/helpers/test-hydrate.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as LWC from 'lwc';
import { spyConsole } from './console';
import { setHooks } from './hooks';

window.TestUtils.setHooks({
sanitizeHtmlContent: (content) => content,
});
setHooks({ sanitizeHtmlContent: (content) => content });

function parseStringToDom(html) {
return Document.parseHTMLUnsafe(html).body.firstChild;
Expand All @@ -28,7 +28,7 @@ async function runTest(ssrRendered, Component, testConfig) {
let target = container.querySelector(selector);

let testResult;
const consoleSpy = window.TestUtils.spyConsole();
const consoleSpy = spyConsole();
setFeatureFlags(testConfig.requiredFeatureFlags, true);

if (testConfig.test) {
Expand Down
6 changes: 0 additions & 6 deletions packages/@lwc/integration-not-karma/mocks/lwc.mjs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous PR was supposed to rename lwc.mjs to lwc.js; apparently lwc.js was added but this was not removed.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createElement } from 'lwc';
import Light from 'x/light';
import Shadow from 'x/shadow';
import {
attachReportingControlDispatcher,
detachReportingControlDispatcher,
nonStandardAriaProperties,
} from 'test-utils';
import Light from 'x/light';
import Shadow from 'x/shadow';
} from '../../../helpers/utils.js';

// This test only works if the ARIA reflection polyfill is loaded
describe.runIf(process.env.ENABLE_ARIA_REFLECTION_GLOBAL_POLYFILL)(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { createElement } from 'lwc';
import { attachReportingControlDispatcher, detachReportingControlDispatcher } from 'test-utils';

import AriaContainer from 'x/ariaContainer';
import Valid from 'x/valid';
import {
attachReportingControlDispatcher,
detachReportingControlDispatcher,
} from '../../../helpers/utils.js';

const expectedMessageForCrossRoot =
'Error: [LWC warn]: Element <input> uses attribute "aria-labelledby" to reference element <label>, which is not in the same shadow root. This will break in native shadow DOM. For details, see: https://sfdc.co/synthetic-aria\n<x-aria-source>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import UiAnother from 'ui/another';
import UiOutputPercent from 'ui/outputpercent';
import ForceFoo from 'force/foo';
import NestedHtmlTags from 'nested/htmlTags';
import { extractDataIds } from 'test-utils';
import { extractDataIds } from '../../helpers/utils.js';
import testProps from './act-components/test-props';
import testAttrs from './act-components/test-attrs';
import testBodySlot from './act-components/test-body-slot';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LightningElement } from 'lwc';
import { USE_COMMENTS_FOR_FRAGMENT_BOOKENDS } from 'test-utils';

import ReflectElement from 'x/reflect';
import LifecycleParent from 'x/lifecycleParent';
Expand All @@ -10,6 +9,8 @@ import AttrChanged from 'x/attrChanged';
import ReflectCamel from 'x/reflectCamel';
import WithChildElmsHasSlot from 'x/withChildElmsHasSlot';
import WithChildElmsHasSlotLight from 'x/withChildElmsHasSlotLight';
import { spyConsole } from '../../../helpers/utils.js';
import { USE_COMMENTS_FOR_FRAGMENT_BOOKENDS } from '../../../helpers/utils.js';

const vFragBookend = USE_COMMENTS_FOR_FRAGMENT_BOOKENDS ? '<!---->' : '';

Expand Down Expand Up @@ -68,7 +69,7 @@ it('should create custom element if it exists before customElements.define', ()
describe('non-empty custom element', () => {
let consoleSpy;
beforeEach(() => {
consoleSpy = TestUtils.spyConsole();
consoleSpy = spyConsole();
});
afterEach(() => {
consoleSpy.reset();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { createElement, LightningElement, setFeatureFlagForTest } from 'lwc';
import { isNativeShadowRootInstance, isSyntheticShadowRootInstance } from 'test-utils';

import Test from 'x/test';
import ShadowRootGetter from 'x/shadowRootGetter';
import {
isNativeShadowRootInstance,
isSyntheticShadowRootInstance,
} from '../../../helpers/utils.js';

function testInvalidOptions(type, option) {
it(`throws a TypeError if option is a ${type}`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { registerTemplate, freezeTemplate, setFeatureFlagForTest } from 'lwc';

import { attachReportingControlDispatcher, detachReportingControlDispatcher } from 'test-utils';
import {
attachReportingControlDispatcher,
detachReportingControlDispatcher,
} from '../../../helpers/utils.js';

describe('freezeTemplate', () => {
let dispatcher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { LightningElement, api, getComponentDef, createElement } from 'lwc';
import { ariaProperties } from 'test-utils';

import PublicProperties from 'x/publicProperties';
import PublicAccessors from 'x/publicAccessors';
Expand All @@ -8,6 +7,7 @@ import PublicPropertiesInheritance from 'x/publicPropertiesInheritance';
import PublicMethodsInheritance from 'x/publicMethodsInheritance';
import PrivateAccessors from 'x/privateAccessors';
import HtmlElementProps from 'x/htmlElementProps';
import { ariaProperties } from '../../../helpers/utils.js';

function testInvalidComponentConstructor(name, ctor) {
it(`should throw for ${name}`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createElement } from 'lwc';
import { getHooks, setHooks } from 'test-utils';

import XInnerHtml from 'x/innerHtml';
import { getHooks, setHooks } from '../../../helpers/utils.js';

const ACTUAL_CONTENT = 'Hello <b>World</b>';
const ALTERNATIVE_CONTENT = 'Hello <b>LWC</b>';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createElement } from 'lwc';
import { spyConsole } from 'test-utils';

import EventHandler from 'x/eventHandler';
import EventHandlerOptions from 'x/eventHandlerOptions';
import AdditionWhileDispatch from 'x/additionWhileDispatch';
import { spyConsole } from '../../../helpers/utils.js';

it('should be able to attach an event listener on the host element', () => {
let thisValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { createElement } from 'lwc';
import {
customElementCallbackReactionErrorListener,
ENABLE_ELEMENT_INTERNALS_AND_FACE,
IS_SYNTHETIC_SHADOW_LOADED,
} from 'test-utils';

import ShadowDomCmp from 'ai/shadowDom';
import LightDomCmp from 'ai/lightDom';
import BasicCmp from 'ai/basic';
import {
customElementCallbackReactionErrorListener,
ENABLE_ELEMENT_INTERNALS_AND_FACE,
IS_SYNTHETIC_SHADOW_LOADED,
} from '../../../../helpers/utils.js';

const testConnectedCallbackError = (elm, msg) => {
const error = customElementCallbackReactionErrorListener(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { createElement } from 'lwc';
import { ENABLE_ELEMENT_INTERNALS_AND_FACE, IS_SYNTHETIC_SHADOW_LOADED } from 'test-utils';

import NotFormAssociated from 'x/notFormAssociated';
import FormAssociated from 'x/formAssociated';
import FormAssociatedFalse from 'x/formAssociatedFalse';
import NotFormAssociatedNoAttachInternals from 'x/notFormAssociatedNoAttachInternals';
import FormAssociatedNoAttachInternals from 'x/formAssociatedNoAttachInternals';
import FormAssociatedFalseNoAttachInternals from 'x/formAssociatedFalseNoAttachInternals';
import {
ENABLE_ELEMENT_INTERNALS_AND_FACE,
IS_SYNTHETIC_SHADOW_LOADED,
} from '../../../../../helpers/utils.js';

describe.runIf(
ENABLE_ELEMENT_INTERNALS_AND_FACE &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LightningElement, api } from 'lwc';
import { ariaProperties } from 'test-utils';
import { ariaProperties } from '../../../../../../../helpers/utils.js';

export default class extends LightningElement {
@api
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { createElement } from 'lwc';
import { ariaProperties, ariaAttributes, ENABLE_ELEMENT_INTERNALS_AND_FACE } from 'test-utils';

import ElementInternal from 'ei/component';
import {
ariaProperties,
ariaAttributes,
ENABLE_ELEMENT_INTERNALS_AND_FACE,
} from '../../../../../helpers/utils.js';

let elm;
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createElement } from 'lwc';
import { customElementCallbackReactionErrorListener } from 'test-utils';

import Test from 'x/test';
import ConnectedCallbackThrow from 'x/connectedCallbackThrow';
import XSlottedParent from 'x/slottedParent';
import { customElementCallbackReactionErrorListener } from '../../../helpers/utils.js';

function testConnectSlot(name, fn) {
it(`should invoke the connectedCallback the root element is added in the DOM via ${name}`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createElement } from 'lwc';
import { customElementCallbackReactionErrorListener } from 'test-utils';

import Slotted from 'x/slotted';
import Test from 'x/test';
import DisconnectedCallbackThrow from 'x/disconnectedCallbackThrow';
import DualTemplate from 'x/dualTemplate';
import ExplicitRender from 'x/explicitRender';
import { customElementCallbackReactionErrorListener } from '../../../helpers/utils.js';

function testDisconnectSlot(name, fn) {
it(`should invoke the disconnectedCallback when root element is removed from the DOM via ${name}`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createElement } from 'lwc';
import { catchUnhandledRejectionsAndErrors } from 'test-utils';
import XBoundaryChildConstructorThrow from 'x/boundaryChildConstructorThrow';
import XBoundaryChildConnectedThrow from 'x/boundaryChildConnectedThrow';
import XBoundaryChildRenderThrow from 'x/boundaryChildRenderThrow';
Expand Down Expand Up @@ -31,6 +30,7 @@ import XParentThrowsOnMutateChildRenderedThrows from 'x/parentThrowsOnMutateChil
import XParentThrowsOnMutateChildConnectedThrows from 'x/parentThrowsOnMutateChildConnectedThrows';

import XNoThrowOnMutate from 'x/noThrowOnMutate';
import { catchUnhandledRejectionsAndErrors } from '../../../helpers/utils.js';

describe('error boundary', () => {
it('should propagate frozen error to errorCallback()', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createElement } from 'lwc';
import { ENABLE_THIS_DOT_HOST_ELEMENT } from 'test-utils';

import Wrapper from 'x/wrapper';
import { ENABLE_THIS_DOT_HOST_ELEMENT } from '../../../helpers/utils.js';

function createWrapper() {
const elm = createElement('x-wrapper', { is: Wrapper });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createElement, registerTemplate } from 'lwc';
import { customElementCallbackReactionErrorListener } from 'test-utils';

import DynamicTemplate, { template1, template2 } from 'x/dynamicTemplate';
import RenderThrow from 'x/renderThrow';
import RenderInvalid from 'x/renderInvalid';
import { customElementCallbackReactionErrorListener } from '../../../helpers/utils.js';

function testInvalidTemplate(type, template) {
it(`throws an error if returns ${type}`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createElement } from 'lwc';
import { ENABLE_THIS_DOT_STYLE } from 'test-utils';
import Test from 'x/test';
import { ENABLE_THIS_DOT_STYLE } from '../../../helpers/utils.js';

it.runIf(ENABLE_THIS_DOT_STYLE)(
'this.style should return the CSSStyleDeclaration of host element',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createElement } from 'lwc';
import { ariaPropertiesMapping, extractDataIds } from 'test-utils';
import NoPropDeclared from 'x/noPropDeclared';
import PropDeclared from 'x/propDeclared';
import ApiPropDeclared from 'x/apiPropDeclared';
Expand All @@ -8,6 +7,7 @@ import NoPropDeclaredNoSuper from 'x/noPropDeclaredNoSuper';
import PropDeclaredNoSuper from 'x/propDeclaredNoSuper';
import ApiPropDeclaredNoSuper from 'x/apiPropDeclaredNoSuper';
import TrackPropDeclaredNoSuper from 'x/trackPropDeclaredNoSuper';
import { ariaPropertiesMapping, extractDataIds } from '../../../helpers/utils.js';

describe('aria reflection', () => {
// Test with and without a custom superclass, since we may set the property accessor differently in each case
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createElement, LightningElement, api } from 'lwc';
import { getPropertyDescriptor } from 'test-utils';

import GetterSetterAndProp from 'x/getterSetterAndProp';
import Properties from 'x/properties';
Expand All @@ -14,6 +13,7 @@ import ExtendsMixin from 'x/extendsMixin';
import StaticProperty from 'x/staticProperty';
import duplicatePropertyTemplate from 'x/duplicatePropertyTemplate';
import NoSetter from 'x/noSetter';
import { getPropertyDescriptor } from '../../../../helpers/utils.js';

describe('properties', () => {
it('should expose class properties with the api decorator', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LightningElement, api } from 'lwc';
import { getPropertyDescriptor } from 'test-utils';
import { getPropertyDescriptor } from '../../../../../../helpers/utils.js';

export default class GetterSetter extends LightningElement {
_getterSetterProp;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Component from 'x/component';
import { createElement } from 'lwc';
import { extractDataIds } from 'test-utils';
import ExportAsDefault from 'x/exportAsDefault';
import ExportAsDefaultWithOtherExports, {
exportee as exporteeAsDefault,
} from 'x/exportAsDefaultWithOtherExports';
import ExportDefaultClassWithOtherExports, {
exportee as exporteeDefaultClass,
} from 'x/exportDefaultClassWithOtherExports';
import { extractDataIds } from '../../../helpers/utils.js';

describe('default export', () => {
it('should work when a module exports non-components as default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import LwcDynamicSlotted from 'x/lwcDynamicSlotted';
import ContainerFoo from 'x/containerFoo';
import ContainerBar from 'x/containerBar';

import { registerForLoad, clearRegister, spyConsole } from 'test-utils';
import { registerForLoad, clearRegister, spyConsole } from '../../../helpers/utils.js';

beforeEach(() => {
clearRegister();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createElement } from 'lwc';
import { ENABLE_ELEMENT_INTERNALS_AND_FACE } from 'test-utils';

import Container from 'x/container';
import FormAssociated from 'x/formAssociated';
import NotFormAssociated from 'x/notFormAssociated';
import LightDomFormAssociated from 'x/lightDomFormAssociated';
import LightDomNotFormAssociated from 'x/lightDomNotFormAssociated';
import { ENABLE_ELEMENT_INTERNALS_AND_FACE } from '../../../helpers/utils.js';

const createFormElement = () => {
const container = createElement('face-container', { is: Container });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { createElement, setFeatureFlagForTest } from 'lwc';
import { attachReportingControlDispatcher, detachReportingControlDispatcher } from 'test-utils';

import Component from 'x/component';
import Parent from 'x/parent';
import LogsWhenConnected from 'x/logsWhenConnected';
import {
attachReportingControlDispatcher,
detachReportingControlDispatcher,
} from '../../../helpers/utils.js';

let logger;
let dispatcher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createElement } from 'lwc';
import { ariaProperties } from 'test-utils';

import Component from 'x/component';
import { ariaProperties } from '../../../helpers/utils.js';

// This list can grow as we add more properties to the base LightningElement
const expectedEnumerableProps = [
Expand Down
Loading