Skip to content

bug: The "st:app:start" performance mark has not been set for vitest with dist-custom-elements output target #6818

Description

@nilsfr

Prerequisites

Stencil Version

4.43.5

Current Behavior

When running test using vitest with a dist-custom-elements output target I get the following error after the test run:

SyntaxError: The "st:app:start" performance mark has not been set                                                                                                         
 ❯ getMark node:internal/perf/usertiming:65:11                                                                                                                            
 ❯ calculateStartDuration node:internal/perf/usertiming:212:13                                                                                                            
 ❯ measure node:internal/perf/usertiming:230:7                                                                                                                            
 ❯ Performance.measure node:internal/perf/performance:134:12                                                                                                              
 ❯ appDidLoad dist/components/node_modules/@stencil/core/internal/client/index.js:3456:17                                                                                 
 ❯ postUpdateComponent dist/components/node_modules/@stencil/core/internal/client/index.js:3404:9                                                                         
 ❯ postUpdate dist/components/node_modules/@stencil/core/internal/client/index.js:3323:30                                                                                 
 ❯ updateComponent dist/components/node_modules/@stencil/core/internal/client/index.js:3325:7                                                                             
 ❯ dist/components/node_modules/@stencil/core/internal/client/index.js:3273:38                                                                                            
 ❯ enqueue dist/components/node_modules/@stencil/core/internal/client/index.js:3278:6

This happen even if the test succeeds.

Expected Behavior

The test runs without error when test succeeds.

System Info

Steps to Reproduce

Use the following stencil.config.ts:

export const config: Config = {
    buildDist: true,
    outputTargets: [
        {
            type: 'dist-custom-elements',
            externalRuntime: false
        }
    ]
};

The error occur if externalRuntime is false.

vitest.config.mts

import { defineVitestConfig } from '@stencil/vitest/config';

export default defineVitestConfig({
    stencilConfig: './stencil.config.ts',
    test: {
        projects: [
            {
                test: {
                    name: 'spec',
                    include: ['test/**/*.spec.{ts,tsx}'],
                    environment: 'stencil',
                    setupFiles: ['./vitest-setup.mts'],
                },
            }
        ],
    },
});

vitest-setup.mts:

import { defineCustomElement} from "./dist/components/prefix-component.js";
defineCustomElement();

Run npx stencil-test --project spec.

Code Reproduction URL

?

Additional Information

If I put performance.mark('st:app:start'); in vitest-setup.mts I no longer trigger the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions