jest-circus-allure-environment icon indicating copy to clipboard operation
jest-circus-allure-environment copied to clipboard

Error from prettier, when test start

Open IvanSavoskin opened this issue 3 years ago • 4 comments

Describe the bug

When starting the test, the following error occurs

Test suite failed to run

    SyntaxError: Identifier expected. (1:10)
    > 1 | function () {
        |          ^
      2 |       return _ref4.apply(this, arguments);
      3 |     }

      at e (node_modules/prettier/parser-typescript.js:1:322)
      at node_modules/prettier/parser-typescript.js:1:3179371
      at Object.parse (node_modules/prettier/parser-typescript.js:1:3179404)
      at Object.parse (node_modules/prettier/standalone.js:15:105894)
      at jp (node_modules/prettier/standalone.js:15:129009)
      at Vp (node_modules/prettier/standalone.js:15:131628)
      at node_modules/prettier/standalone.js:55:38189
      at Object.format (node_modules/prettier/standalone.js:55:38272)
      at AllureReporter.extractCodeDetails (node_modules/jest-circus-allure-environment/src/allure-reporter.ts:320:19)
      at AllureReporter.startTestCase (node_modules/jest-circus-allure-environment/src/allure-reporter.ts:166:43)

To Reproduce

Code test

it("Editor helper test", async () => {
     await editorHelpersTest(mockFunctionsList);
 });

This is test ts file

IvanSavoskin avatar May 21 '21 17:05 IvanSavoskin

Hey @IvanSavoskin :wave:

Thanks for opening this bug. I'm not able to reproduce what you have reported above. Have you tried testing on a dummy test? Something simple like:

test('Expect to pass', () => {
	expect(1 + 2).toBe(3);
});

This would help us narrow down the issue. Any additional implementation details such as package version, jest config setup, and tests would be helpful too. 😄

ryparker avatar Jun 21 '21 07:06 ryparker

@ryparker I am facing the exactly same problem, reported from many unexpected places. Environment:

  • node 14.16.1
  • npm 7.14.0
  • jest 27.0.4
  • "jest-circus-allure-environment": "^1.1.1"
  • "ts-node": "^9.1.1"
  • "ts-jest": "^27.0.3",

E.g.:

SyntaxError: ',' expected. (6:7)
      4 |                 paymentMethod: {
      5 |                     // @ts-
    > 6 | expect-error: fake payment method name
        |       ^
      7 |                     getName() {
      8 |                         return "ExternalPaymentMethod";
      9 |                     },

      at e (node_modules/prettier/parser-typescript.js:1:322)
      at node_modules/prettier/parser-typescript.js:1:3179371
      at Object.parse (node_modules/prettier/parser-typescript.js:1:3179404)
      at Object.parse (node_modules/prettier/standalone.js:15:105894)
      at jp (node_modules/prettier/standalone.js:15:129009)
      at Vp (node_modules/prettier/standalone.js:15:131628)
      at node_modules/prettier/standalone.js:55:38189
      at Object.format (node_modules/prettier/standalone.js:55:38272)
      at AllureReporter.extractCodeDetails (node_modules/jest-circus-allure-environment/src/allure-reporter.ts:320:19)
      at AllureReporter.startTestCase (node_modules/jest-circus-allure-environment/src/allure-reporter.ts:166:43)

UPDATE: This is only thrown if testEnvironment is set to "jest-circus-allure-environment"; when it's "node", then tests run okay.

rodush avatar Jun 22 '21 08:06 rodush

I guess, the issue around @ts-expect-error is the regex here - https://github.com/ryparker/jest-circus-allure-environment/blob/main/src/allure-reporter.ts#L319 , where it should actually check for word boundary with a \b, for instance

rodush avatar Jun 22 '21 09:06 rodush

@ryparker any ETA to fix it or @rodush/ @IvanSavoskin maybe you have some workaround

Naimadnap avatar Aug 04 '21 14:08 Naimadnap