question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Use existing vite.config.js file for component tests

See original GitHub issue

I have a project that already uses Vite, and is configured with the vite-tsconfig-paths plugin to resolve my paths correctly. It looks like Playwright’s new component testing feature doesn’t use my existing vite.config.js file as it errors when trying to resolve a path that needs to follow my tsconfig path resolution logic.

It’d be nice if Playwright could make use of my custom config and just extend it to point to the correct entry point (e.g. playwright/index.html), or at least allow for configuring extra plugins for Playwright’s vite config to work correctly.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
AlexanderMykulychcommented, Jun 9, 2022

Had the same problem, some of my configurations applied, and some did not. I’ve written my custom vite plugin and defined there config function: image

image

It helped.

2reactions
rwollcommented, May 19, 2022

It’s not yet documented[^1], but you can explicitly configure the config (along with a few other options) via: https://github.com/microsoft/playwright/blob/fbb364c1cd0dec9e4a75b885d51e67ca397b1d6a/packages/playwright-ct-react/index.d.ts#L33

import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react';
import { devices } from '@playwright/experimental-ct-react';

/**
 * See https://playwright.dev/docs/test-configuration.
 */
const config: PlaywrightTestConfig = {
  // …
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  use: {
    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    trace: 'on-first-retry',

    /* Port to use for Playwright component endpoint. */
    ctPort: 3100,

    /* Vite config */
    ctViteConfig: {},
  },

  /* Configure projects for major browsers */
  projects: [
    // …
  ],
};

export default config;

Give it a try and let us know how it goes! If you encounter any issues or have questions, feel free to comment here or open up another issue.

[^1]: Since we announced the feature as a preview, we have not yet given the docs the ❤️ they deserve…yet!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Vite
When running vite from the command line, Vite will automatically try to resolve a config file named vite.config.js inside project root.
Read more >
Testing Vite with minimal config using Vitest - LogRocket Blog
js file as our website's entry point, it crawls HTML files to track all JavaScript, styles, and miscellaneous assets you use. This enables...
Read more >
Testing with Vitest - This Dot Labs
Vitest is a new testing framework powered by Vite. It's still in development, and some features may not be ready yet, but it's...
Read more >
Configuring Vitest
To configure vitest itself, add test property in your Vite config. ... When using a separate vitest.config.js , you can also extend Vite's...
Read more >
Getting Started with Vitest | Vue Mastery
It uses the Vite dev server to transform your files during testing and listens to the same configuration of your app (through ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found