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

Environment variable DEBUG_PRINT_LIMIT not working for me #55

Open
tmalahie opened this issue May 8, 2021 · 4 comments
Open

Environment variable DEBUG_PRINT_LIMIT not working for me #55

tmalahie opened this issue May 8, 2021 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@tmalahie
Copy link

tmalahie commented May 8, 2021

I was trying to use the environment variable, DEBUG_PRINT_LIMIT, to limit the length of the HTML printed to console in case of failure.
But for some reasons, the variable environment is just ignored by the library...

My project:

package.json

{
  "scripts": {
    "test": "jest --detectOpenHandles"
  },
  "devDependencies": {
    "jest": "^26.6.3",
    "pptr-testing-library": "^0.6.4",
    "puppeteer": "^2.1.1"
  }
}

main.test.js

const puppeteer = require('puppeteer')
require('pptr-testing-library/extend')

test('Should go to the forum', async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto("https://mkpc.malahieude.net");
    const $document = await page.getDocument();
    const $forum = await $document.getByText("Forum");
});

Now when I run DEBUG_PRINT_LIMIT=10 npm test, the environment variable is just ignored since it prints me the whole HTML instead of just 10 characters...

I tried many things: setting the environment variable in the package.json file, or directly in my code, but nothing works, the variable is just ignored.

However if I change the code of the library (file pptr-testing-library/dom-testing-library.js), and I replace process.env.DEBUG_PRINT_LIMIT || 7000 with process.env.DEBUG_PRINT_LIMIT || 10, then it works! So it seems that for some reason the environment variable is not passed correctly to the library.

I'm using node version 12 on a Debian machine (I think it doesn't change anything though).

Is it a bug in the library or am I doing something wrong?

Thanks

@patrickhulce
Copy link
Collaborator

Thanks for filing @tmalahie !

So it seems that for some reason the environment variable is not passed correctly to the library.

Correct this library does not even attempt to pass environment variables through. dom-testing-library is executed inside the browser context which does not have any access to the environment variables in node.

We'd accept a PR that injected relevant variables though :)

@nickserv nickserv added bug Something isn't working help wanted Extra attention is needed labels Jul 11, 2021
@Izhaki
Copy link

Izhaki commented May 10, 2022

I don't think DEBUG_PRINT_LIMIT works with dom-testing-library.

The way to go about this is providing getElementError to configure (see docs and related GitHub issue).

However, pptr-testing-library does not support this at the moment. Not sure how hard supporting this will be, the support for testIdAttribute does not look like a straight-forward delegation.

@Yorkshireman
Copy link

Has this been fixed?

@patrickhulce
Copy link
Collaborator

@Yorkshireman nope.

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

No branches or pull requests

5 participants