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

Default --preset=expo workspace .toHaveTextContent in App.spec.tsx contains a TypeScript error #23027

Closed
1 of 4 tasks
danharten-sovtech opened this issue Apr 26, 2024 · 2 comments · Fixed by #23314
Closed
1 of 4 tasks
Assignees
Labels
scope: react-native Issues relating to React Native type: bug

Comments

@danharten-sovtech
Copy link

Current Behavior

Currently, .toHaveTextContent greets the developer with: Property 'toHaveTextContent' does not exist on type 'JestMatchers<ReactTestInstance>'.

Expected Behavior

No TypeScript error.

To fix this, update tsconfig.spec.json types to include the appropriate types, like so: "types": ["jest", "node", "@testing-library/jest-native"]

This way, the expo preset can be presented error free.

GitHub Repo

No response

Steps to Reproduce

  1. run npx create-nx-workspace@latest --preset=expo --appName=your-app-name
  2. Navigate to app/App.spec.tsx
  3. See typescript error

Nx Report

Node   : 20.9.0
OS     : darwin-arm64
npm    : 10.1.0

nx (global)        : 18.3.2
nx                 : 18.3.4
@nx/js             : 18.3.4
@nx/jest           : 18.3.4
@nx/linter         : 18.3.4
@nx/eslint         : 18.3.4
@nx/workspace      : 18.3.4
@nx/detox          : 18.3.4
@nx/devkit         : 18.3.4
@nx/eslint-plugin  : 18.3.4
@nx/expo           : 18.3.4
@nx/react          : 18.3.4
@nrwl/tao          : 18.3.4
@nx/web            : 18.3.4
@nx/webpack        : 18.3.4
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/expo/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/detox/plugin

Failure Logs

No response

Package Manager Version

1.22.19

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@AgentEnder AgentEnder added the scope: react-native Issues relating to React Native label Apr 29, 2024
@xiongemi
Copy link
Collaborator

xiongemi commented May 10, 2024

or you can fix it by adding the setup file:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "module": "commonjs",
    "types": ["jest", "node"]
  },
  "files": ["./test-setup.ts"], // <-- points to test setup file
  "include": [
    "jest.config.ts",
    "src/**/*.test.ts",
    "src/**/*.spec.ts",
    "src/**/*.test.tsx",
    "src/**/*.spec.tsx",
    "src/**/*.test.js",
    "src/**/*.spec.js",
    "src/**/*.test.jsx",
    "src/**/*.spec.jsx",
    "src/**/*.d.ts"
  ]
}

I will do a proper fix.

@danharten-sovtech
Copy link
Author

Thank you @xiongemi! Really appreciate it.

xiongemi added a commit that referenced this issue May 17, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #23027
#22198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: react-native Issues relating to React Native type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants