chromaui / chromatic-e2e

Archive end-to-end tests to be replayed in Storybook and Chromatic
MIT License
12 stars 3 forks source link

@chromatic-com/playwright - Tests with titlePaths greater than 255 characters result in ENAMETOOLONG errors during write snapshot file step #169

Open ryan-case-ml opened 4 days ago

ryan-case-ml commented 4 days ago

Describe the bug I have some pretty descriptive playwright tests because I like to be as declarative as possible to explain the test cases. Usually I have a test file named after the feature, a describe block to group tests by a set of mock data they are testing against, and then the test description itself. My tests are organized in sub directories by module as well (e.g. @core). This makes for some pretty long titlePaths at times. It would be nice if we either truncated long titlePaths by default, or exposed a config prop to use just the title instead. UPDATE - see comment below for a possible better suggestion

To Reproduce Steps to reproduce the behavior:

  1. Install @playwright/testv1.41.0
  2. Create a playwright test file with the following folder structure
    📦e2e
    ┣ 📂tests
    ┃ ┣ 📂@core
    ┃ ┃ ┣ 📜SomeFeatureName.spec.ts
  3. Set up your playwright.config file to the following bare minimum
    
    /** ./playwright.config.ts */
    import { defineConfig, devices } from '@playwright/test';

export default defineConfig({ / Tell playwright where our tests can be found / testDir: './e2e/tests', outputDir: 'e2e/test-outputs/test-results', projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'], }, }, ], )}


4. Create a generic test in `SomeFeatureName.spec.ts` grouped by a describe block title and test title that would put the full titlePath at above 255 characters.
5. Recieve the following error
`Error: ENAMETOOLONG: name too long`

**Expected behavior**
The snapshot should not fail to be generated. This should be handled more gracefully or allow for a config to get around it. This should also be documented.
ryan-case-ml commented 4 days ago

I actually tried patching this myself to use the test id in the file name instead of the full test file path when creating the archive files and it seems to work nice. lmk if you'd be interested in me cutting a PR for that