1

The official introduction React Testing Library | Testing Library links to a tutorial page React Testing Library Tutorial. In the tutorial it says "After running your test on the command line, you should see the HTML output of your App component". First of all, what tf does this the command mean?? I thought, but anyways I tried npx jest, got an error as the title, the detailed error as the below:

 FAIL  src/App.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

I guess the tutorial is for create-react-app users maybe, but I don't use it and I'm on Webpack. Even if I needed to do something to get the thing working, I have no clue what I need to do on my package.json/.babelrc/webpack.config.js etc, because the intro/tutorial didn't clarify it.

So, 1. What can I do to make the thing working? 2. Is there a decent official/non-official step by step doc/tutorial?; Thanks.

  • `the command line` means the the terminal. Also look into configuring Jest, https://jestjs.io/docs/configuration – Badal Saibo Aug 09 '22 at 06:46
  • I know, not `the command line`, `the command`. I mean I have/had no idea what `command` the article means. `npx jest`? something else? I mean `jest` is not a only thing that react-testing-library can work with, correct? The article didn't say "`I'm going to use Jest on it" or something. So I'm confused. Thanks for the link, I'm taking a look. – 丶 Limeー来夢 丶 Aug 09 '22 at 06:51
  • Where is `the command` written? EDIT: I saw its written in the linked article. Your interpretation of the command is correct. It is `npx jest` – Badal Saibo Aug 09 '22 at 09:08
  • Yes. So I think I gotta follow e.g. this https://jestjs.io/docs/tutorial-react that installs `npm install --save-dev jest babel-jest .. etc` so that above mentioned error would go away and react-testing-library should be working, correct, I guess? – 丶 Limeー来夢 丶 Aug 09 '22 at 09:23
  • Yes. I hope so. – Badal Saibo Aug 09 '22 at 09:29

0 Answers0