Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:
run: yarn test:types
- name: Run unit tests
run: yarn test:ci
- name: Run unit tests in production mode
run: NODE_ENV=production yarn test:ci
- name: Upload unit test coverage report
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"copy-fork": "./scripts/tasks/unsafe-external-contributor-ci-workaround.sh",
"dev": "nx run-many --target=dev --all --parallel=999 --exclude=@lwc/perf-benchmarks,@lwc/perf-benchmarks-components,@lwc/integration-tests",
"test": "vitest --workspace vitest.workspace.mjs",
"test:production": "VITE_NODE_ENV=production vitest --workspace vitest.workspace.mjs",
"test:bespoke": "nx run-many --target=test",
"test:debug": "vitest --workspace vitest.workspace.mjs --inspect-brk --no-file-parallelism",
"test:ci": "vitest run --workspace vitest.workspace.mjs --coverage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { LOWEST_API_VERSION } from '@lwc/shared';

// it needs to be imported from the window, otherwise the checks for associated vms is done against "@lwc/engine-core"
const LightningElementFormatter = (globalThis as any)['devtoolsFormatters'].find((f: any) => {
const LightningElementFormatter = (globalThis as any)['devtoolsFormatters']?.find((f: any) => {
return f.name === 'LightningElementFormatter';
});

Expand All @@ -33,8 +33,9 @@ class WireAdapter {
disconnect() {}
}

describe('Lightning Element formatter', () => {
const { header } = LightningElementFormatter;
// LightningElementFormatter is not exposed in prod mode
describe.skipIf(process.env.NODE_ENV === 'production')('Lightning Element formatter', () => {
const header = LightningElementFormatter?.header;

it('should not contain body', () => {
expect(LightningElementFormatter.hasBody()).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { testFixtureDir, formatHTML, pluginVirtual } from '@lwc/test-utils-lwc-i
import { setFeatureFlagForTest } from '../index';
import type { LightningElementConstructor } from '@lwc/engine-core/dist/framework/base-lightning-element';
import type { RollupLwcOptions } from '@lwc/rollup-plugin';
import type { FeatureFlagName } from '@lwc/features/dist/types';

vi.mock('lwc', async () => {
const lwcEngineServer = await import('../index');
Expand All @@ -33,6 +34,9 @@ interface FixtureConfig {

/** Props to provide to the root component. */
props?: Record<string, string>;

/** Feature flags to enable for the test. */
features: FeatureFlagName[];
}

async function compileFixture({
Expand Down Expand Up @@ -162,7 +166,8 @@ function testFixtures(options?: RollupLwcOptions) {
);
}

describe.concurrent('fixtures', () => {
// TODO [#5134]: Enable these tests in production mode
describe.skipIf(process.env.NODE_ENV === 'production').concurrent('fixtures', () => {
beforeAll(() => {
// ENABLE_WIRE_SYNC_EMIT is used because this mimics the behavior for LWR in SSR mode. It's also more reasonable
// for how both `engine-server` and `ssr-runtime` behave, which is to use sync rendering.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe.each(
`;
const doReplacement = () => tmpl(b.literal('I am not an identifier') as any);
expect(doReplacement).toThrow(
'Validation failed for templated node. Expected type identifier, but received Literal.'
/^Validation failed for templated node\. Expected type .+?, but received Literal\.$/
);
});
});
Expand Down
5 changes: 4 additions & 1 deletion vitest.shared.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import inspector from 'node:inspector';
import process from 'node:process';
import { defineConfig } from 'vitest/config';
import pkg from './package.json';

export default defineConfig({
test: {
env: {
NODE_ENV: process.env.VITE_NODE_ENV,
},
// Don't time out if we detect a debugger attached
testTimeout: inspector.url()
? // Largest allowed delay, see https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value
Expand Down
Loading