Skip to content

The generated dataset is incorrect #51

@cnlinxi

Description

@cnlinxi

Hello authors, following the steps in the README, I focused on generating unit tests for JavaScript/TypeScript, but the results I got did not look right. For example:

{
 "test_id": "newsuk__times-components-565/times-components-dc6f1a855f0d5868f4fe817f17174e49e9915da6/packages/jest-configurator/__tests__/jest-configurator.test.js::\"Jest Configurator Tests\"",
 "test": "() => {\n  describe(\"All platforms\", () => {\n    it(\"should always use react-native preset\", () => {\n      const config = jestConfigurator(\"android\", dir);\n      expect(config.preset).toEqual(\"react-native\");\n    });\n\n    it(\"should have a test match applying to the right directory based on params\", () => {\n      const config = jestConfigurator(\"android\", dir);\n      expect(config.testMatch).toContain(\n        path.join(dir, \"/__tests__/android/*.test.js\")\n      );\n    });\n\n    it(\"should ignore jest config\", () => {\n      const config = jestConfigurator(\"android\", dir);\n      expect(config.testPathIgnorePatterns).toContain(\n        path.join(dir, \"/__tests__/android/jest.config.js\")\n      );\n    });\n\n    it(\"should include times-components in transform ignore patterns\", () => {\n      const config = jestConfigurator(\"android\", dir);\n      expect(config.transformIgnorePatterns).toContain(\n        \"node_modules/(?!(react-native|react-native-linear-gradient|@times-components)/)\"\n      );\n    });\n\n    it(\"should make sure the root directory is correct\", () => {\n      const config = jestConfigurator(\"android\", dir);\n      expect(config.rootDir).toEqual(path.resolve(__dirname, \"../\"));\n    });\n\n    it(\"should respect coverage ignore globs\", () => {\n      const config = jestConfigurator(\n        \"android\",\n        path.resolve(__dirname, \"../fixtures/ignore\"),\n        [\"data-helper.js\"]\n      );\n      expect(config.collectCoverageFrom).toEqual([\n        \"**/fixtures/ignore/ignore.js\"\n      ]);\n    });\n  });\n\n  // Web specific\n  describe(\"Web specific configuration\", () => {\n    it(\"should use the module mapper to match react-native to react-native-web\", () => {\n      const config = jestConfigurator(\"web\", dir);\n      expect(config.moduleNameMapper[\"react-native\"]).toEqual(\n        \"react-native-web\"\n      );\n    });\n\n    it(\"should always use jsdom as the test environment\", () => {\n      const config = jestConfigurator(\"web\", dir);\n      expect(config.testEnvironment).toEqual(\"jsdom\");\n    });\n\n    it(\"should have the correct module name extensions\", () => {\n      const config = jestConfigurator(\"web\", dir);\n      expect(config.moduleFileExtensions).toEqual([\"web.js\", \"js\", \"json\"]);\n    });\n  });\n\n  describe(\"Native specific configuration\", () => {\n    it(\"should have a default platform that matches the param in the haste\", () => {\n      const config = jestConfigurator(\"ios\", dir);\n      expect(config.haste.defaultPlatform).toEqual(\"ios\");\n    });\n\n    it(\"should only define the param as the platform used\", () => {\n      const config = jestConfigurator(\"ios\", dir);\n      expect(config.haste.platforms).toEqual([\"ios\"]);\n    });\n\n    it(\"should use the correct module name extensions\", () => {\n      const config = jestConfigurator(\"ios\", dir);\n      expect(config.haste.moduleFileExtensions).toEqual([\n        \"ios.js\",\n        \"native.js\",\n        \"js\",\n        \"json\"\n      ]);\n    });\n  });\n}",
 "code_id": "newsuk__times-components-565/times-components-dc6f1a855f0d5868f4fe817f17174e49e9915da6/packages/jest-configurator/__tests__/jest-configurator.test.js::None",
 "code": "import jestConfigurator from \"../src/jest-configurator\";",
 "docstring": null,
 "test_header": "const config = () => {\n"
}

The code field seems to be just a statement to import the function, not the specific implementation of the function. Is there any solution? Thank you.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions