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

Getting "extra" testcases, one "correct", another with just a Test Execution Failure #220

Closed
azzlack opened this issue Aug 24, 2022 · 3 comments

Comments

@azzlack
Copy link
Contributor

azzlack commented Aug 24, 2022

I'm getting some weird test results when using this.
I get one ESlint testcase that represents the file itself, that is successful - and one testcase for the same file with just an error Test execution failure: could be caused by test hooks like 'afterAll'.

# .eslintrc.js
module.exports = {
  root: true,
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true,
  },
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint', 'tailwindcss'],
  extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:tailwindcss/recommended', 'prettier', 'next/core-web-vitals'],
  ignorePatterns: ["dist/", "node_modules/", ".turbo/", ".next/"],
  rules: {
    '@next/next/no-html-link-for-pages': 'off',
    'react/jsx-key': 'off',
    "react/jsx-max-depth": ["error", { "max": 8 }],
    "react/forbid-component-props": ["error", { "forbid": ['style'] }]
  }
};
# jest.config.js
const fs = require('fs');

const getPackageName = () => {
  packagejson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
  return packagejson.name;
}

module.exports = {
  projects: [
    {
      displayName: 'test'
    },
    {
      displayName: 'lint',
      runner: 'jest-runner-eslint',
      testPathIgnorePatterns: ["/node_modules/", "dist/", ".storybook/", "storybook-static/", ".next/", "build/"],
      testMatch: ['<rootDir>/**/*.{js,ts,tsx}']
    }
  ],
  cacheDirectory: "<rootDir>/../../.jestcache",
  reporters: ["default", ["jest-junit", {
    outputDirectory: "<rootDir>/../../.testresults", 
    outputName: `junit-${getPackageName()}.xml`,
    reportTestSuiteErrors: false,
    includeConsoleOutput: false
  }]],
  collectCoverage: true,
  coverageReporters: [["cobertura", { file: `cobertura-coverage-${getPackageName()}.xml` }]],
  coverageDirectory: "<rootDir>/../../.testresults"
}

Running jest --ci then yields the following result.
(Please note that the failing testcases are not present in the console output, or in the junit output)

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="5" failures="0" errors="0" time="2.047">
  <testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-08-24T13:18:16" time="1.338" tests="1">
    <testcase classname=" ESLint" name=" ESLint" time="1.338">
    </testcase>
    <testcase classname=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." name=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." time="0">
      <failure>null</failure>
    </testcase>
  </testsuite>
  <testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-08-24T13:18:16" time="1.338" tests="1">
    <testcase classname=" ESLint" name=" ESLint" time="1.338">
    </testcase>
    <testcase classname=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." name=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." time="0">
      <failure>null</failure>
    </testcase>
  </testsuite>
  <testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-08-24T13:18:16" time="1.34" tests="1">
    <testcase classname=" ESLint" name=" ESLint" time="1.34">
    </testcase>
    <testcase classname=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." name=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." time="0">
      <failure>null</failure>
    </testcase>
  </testsuite>
  <testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-08-24T13:18:16" time="1.572" tests="1">
    <testcase classname=" ESLint" name=" ESLint" time="1.572">
    </testcase>
    <testcase classname=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." name=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." time="0">
      <failure>null</failure>
    </testcase>
  </testsuite>
  <testsuite name="undefined" errors="0" failures="0" skipped="0" timestamp="2022-08-24T13:18:16" time="1.574" tests="1">
    <testcase classname=" ESLint" name=" ESLint" time="1.574">
    </testcase>
    <testcase classname=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." name=" Test execution failure: could be caused by test hooks like &apos;afterAll&apos;." time="0">
      <failure>null</failure>
    </testcase>
  </testsuite>
</testsuites>

Originally posted at jest-community/jest-runner-eslint#141, but seems like the issue is with this package.

@azzlack azzlack changed the title Getting twice the testcases, one with Test execution failure and one with ESLint #141 Getting twice the testcases, one with Test execution failure and one with ESLint Aug 24, 2022
@azzlack azzlack changed the title Getting twice the testcases, one with Test execution failure and one with ESLint Getting "extra" testcases, one "correct", another with just a Test Execution Failure Aug 24, 2022
@azzlack
Copy link
Contributor Author

azzlack commented Aug 24, 2022

Downgrading to v13.2.0 seems to fix the issue.
#214 looks to have been the one that adds the "fake" testcase, but it seems to not work correctly when testExecError is null, as it only matches undefined ?

@palmerj3
Copy link
Collaborator

palmerj3 commented Aug 25, 2022 via email

@azzlack
Copy link
Contributor Author

azzlack commented Aug 25, 2022

I removed them, without any difference. As you can see from the PR, the issue is with how jest-junit deals with null vs undefined in 14.0.0

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

2 participants