Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error when running with vitest #23

Open
aenand opened this issue Nov 20, 2024 · 2 comments
Open

Syntax error when running with vitest #23

aenand opened this issue Nov 20, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@aenand
Copy link

aenand commented Nov 20, 2024

Hello! I am trying to use this action to track tests for my Javascript app that uses vitest. When following the vitest section of the guide, the command to run the test errors out. Any idea what causes this?

Step:

    - run: npm run build --if-present
    - name: Configure Datadog Test Visibility
      uses: datadog/test-visibility-github-action@v2
      with:
        languages: js
        service: {{ service_name }}
        api_key: ${{ secrets.DD_API_KEY }}
        site: datadoghq.com # Change if your site is not US1
    - name: Run tests
      run: npm run test
      env: 
        NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }} --import ${{ env.DD_TRACE_ESM_IMPORT }}

Error:

failed to load config from {{path_to_file}}/vitest.config.ts

⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯
SyntaxError: Identifier '$haml' has already been declared
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:168:18)
    at callTranslator (node:internal/modules/esm/loader:279:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:30)
@juan-fernandez juan-fernandez self-assigned this Nov 25, 2024
@juan-fernandez juan-fernandez added the bug Something isn't working label Nov 25, 2024
@juan-fernandez
Copy link
Contributor

juan-fernandez commented Nov 25, 2024

hey @aenand !

This seems to be related to a known limitation with import-in-the-middle and ESM:

Until the upstream dependency (import-in-the-middle) is fixed, there's nothing we can do sadly. I'll keep you updated if there are any news.

In any case, if you could share a small reproducible case to confirm my assessment that'd be very useful. You can run your vitests directly without datadog/test-visibility-github-action (see instructions):

    - run: npm run build --if-present
    - name: Install dd-trace
      run: npm install --save-dev dd-trace
    - name: Run tests
      run: npm run test
      env: 
        NODE_OPTIONS: -r dd-trace/ci/init --import dd-trace/register.js

@aenand
Copy link
Author

aenand commented Nov 25, 2024

Gotcha thanks! We use pnpm to manage dependencies so it seems like we might have to add the dd-trace package to our list. Appreciate the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants