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

Cannot properly debug #35

Open
foxt451 opened this issue Nov 23, 2023 · 1 comment
Open

Cannot properly debug #35

foxt451 opened this issue Nov 23, 2023 · 1 comment

Comments

@foxt451
Copy link

foxt451 commented Nov 23, 2023

Source maps are somehow misaligned.
I have a simple test like below:

test('test', async () => {
    console.log('test');
    console.log('test2');
    console.log('test3');
    console.log('test4');
    console.log('test5');
    console.log('test6');
    console.log('test7');
    console.log('test8');
    console.log('test9');
    console.log('test10');
    console.log('test11');
    console.log('test12');
    console.log('test13');
    console.log('test14');
    console.log('test15');
    console.log('test16');
    console.log('test17');
    console.log('test18');
}, 100000000);

When I put a breakpoint at the first line and debug the test, it will print the following:
Debug adapter reported a frame at line 26 column 2, but: Cursor position outside buffer. Ensure executable is up2date and if using a source mapping ensure it is correct
In other cases (some additional lines before the test, or breakpoint in the middle) it will maybe go through a couple lines and then go into vitest's module code. On webstorm debugging my project with vitest works fine
Test is being run (not debugged) fine

@foxt451
Copy link
Author

foxt451 commented Nov 23, 2023

(not sure if that helps but here is my vitest config)

import { cpus } from 'node:os';
import { resolve } from 'node:path';

import isCI from 'is-ci';
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vitest/config';

let threads: { minThreads: number; maxThreads: number } | undefined;

if (isCI) {
    // eslint-disable-next-line no-console
    console.log(`Running in CI, throttling threads to 1 test at a time`);
    threads = { minThreads: 1, maxThreads: 1 };
}

export default defineConfig({
    plugins: [tsconfigPaths()],
    esbuild: {
        target: 'es2022',
        keepNames: true,
    },
    test: {
        globals: true,
        coverage: {
            provider: 'v8',
            reporter: ['text', 'lcov', 'cobertura'],
            exclude: [
                '**/node_modules/**',
                '**/dist/**',
                '**/test/**',
            ],
        },
        restoreMocks: true,
        ...threads,
        testTimeout: 60_000,
        hookTimeout: 60_000,
        alias: [
            { find: 'crawlee', replacement: resolve(__dirname, './packages/crawlee/src') },
            { find: '@crawlee/basic', replacement: resolve(__dirname, './packages/basic-crawler/src') },
            { find: '@crawlee/browser', replacement: resolve(__dirname, './packages/browser-crawler/src') },
            { find: '@crawlee/http', replacement: resolve(__dirname, './packages/http-crawler/src') },
            { find: '@crawlee/linkedom', replacement: resolve(__dirname, './packages/linkedom-crawler/src') },
            { find: '@crawlee/jsdom', replacement: resolve(__dirname, './packages/jsdom-crawler/src') },
            { find: '@crawlee/cheerio', replacement: resolve(__dirname, './packages/cheerio-crawler/src') },
            { find: '@crawlee/playwright', replacement: resolve(__dirname, './packages/playwright-crawler/src') },
            { find: '@crawlee/puppeteer', replacement: resolve(__dirname, './packages/puppeteer-crawler/src') },
            { find: /^@crawlee\/(.*)\/(.*)$/, replacement: resolve(__dirname, './packages/$1/$2') },
            { find: /^@crawlee\/(.*)$/, replacement: resolve(__dirname, './packages/$1/src') },
            { find: /^test\/(.*)$/, replacement: resolve(__dirname, './test/$1') },
        ],
        retry: 3,
    },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant