Open DAMSCROW opened 4 days ago
Here's a template for your tracking sheet to capture requirements for component variations or new components. You can use it in Google Sheets or Excel.
Explanation of Columns:
Component Name: Name of the component needing a variant or new properties.
Existing Component?: Indicates if the Veracle Team already provides this component.
Requested Variants/Modifications: Specific customizations (e.g., color, font, size).
New Properties Needed: Technical names for new properties needed in the code.
Current Limitations: Description of current limitations in the provided component.
Priority: Importance level to help prioritize tasks.
Requested By: Your or your team member’s name to keep track of request origins.
Date Requested: Date when the request was made.
Expected Usage: Where this component will primarily be used (dashboard, mobile, or both).
Status: Tracks the current status, such as "Pending
Subject: Quick Input Needed: Component Requirements for Dashboard & Mobile
Hi Team,
To support our dashboard and mobile development, please add any needed component customizations or new components to our tracking sheet. Include details like the component name, required variants or properties, and usage (Dashboard, Mobile, or Both). This will help us coordinate with the Veracle Team for any necessary updates.
[Link to tracking sheet]
Please complete your entries by [due date]. Thanks for your help!
Best, [Your Name]
Subject: Quick Input Needed: Component Requirements for Dashboard & Mobile
Hi Team,
To support our dashboard and mobile development, please add any needed component customizations or new components to our tracking sheet. Include details like the component name, required variants or properties, and usage (Dashboard, Mobile, or Both). This will help us coordinate with the Veracle Team for any necessary updates.
[Link to tracking sheet]
Please complete your entries by [due date]. Thanks for your help!
Best, [Your Name]
The error message visible in your editor says: "Cannot use JSX unless the '--jsx' flag is provided".
This typically happens because the TypeScript configuration (tsconfig.json) isn't set up to handle JSX syntax. To fix this, you need to make sure the jsx option is correctly set in your tsconfig.json file.
Here’s a revised and more professional version of your query:
"I encountered the error 'Cannot use JSX unless the '--jsx' flag is provided' in index.jsx. I understand that this issue occurs because the TypeScript configuration (tsconfig.json) may not be set up to support JSX syntax. To address this, I updated the tsconfig.json file to include the appropriate jsx option.
Could you confirm if this is the recommended approach, or if there are alternative methods to handle this configuration? Additionally, is this error possibly related to my local setup with pnpm, or something specific to my development environment?"
This phrasing is clear and professional and invites feedback on whether your solution is optimal or if there might be other factors involved.
Here’s a revised and more professional version of your query:
"I encountered the error 'Cannot use JSX unless the '--jsx' flag is provided' in index.jsx. I understand that this issue occurs because the TypeScript configuration (tsconfig.json) may not be set up to support JSX syntax. To address this, I updated the tsconfig.json file to include the appropriate jsx option.
Could you confirm if this is the recommended approach, or if there are alternative methods to handle this configuration? Additionally, is this error possibly related to my local setup with pnpm, or something specific to my development environment?"
This phrasing is clear and professional and invites feedback on whether your solution is optimal or if there might be other factors involved.
For your sprint notes, you could use a headline like:
"Showcasing Visual Directions: User Feedback on MPIR Design Approaches"
Or a tagline:
"Exploring Visual Design for MPIR: Gathering Insights on User Preferences"
Let me know if you'd like any further adjustments!
For your sprint notes, you could use a headline like:
"Showcasing Visual Directions: User Feedback on MPIR Design Approaches"
Or a tagline:
"Exploring Visual Design for MPIR: Gathering Insights on User Preferences"
Let me know if you'd like any further adjustments!
For your sprint notes, you could use a headline like:
"Showcasing Visual Directions: User Feedback on MPIR Design Approaches"
Or a tagline:
"Exploring Visual Design for MPIR: Gathering Insights on User Preferences"
Let me know if you'd like any further adjustments!
Thank you for the context on your setup with the RootLayout component and the HomeScreen component within a stack structure in the Expo-based React Native application. Below, I'll outline a Jest test case for both layout.tsx and index.tsx (HomeScreen) files, ensuring the tests validate the basic rendering and structure of these components.
Jest Test for RootLayout Component (layout.tsx)
This test case will check if the RootLayout component renders the expected stack layout and displays child content correctly.
import React from 'react'; import { render } from '@testing-library/react-native'; import RootLayout from './layout'; import HomeScreen from './screens/index';
describe('RootLayout Component', () => { it('renders RootLayout with child component', () => { // Render RootLayout with a sample child component const { getByText } = render(
);
// Check if HomeScreen content is rendered within the layout
expect(getByText(/welcome message placeholder/i)).toBeTruthy();
});
});
Jest Test for HomeScreen Component (index.tsx)
For HomeScreen, this test will validate the rendering of components like the VStack, Card, and Header from your layout setup.
import React from 'react'; import { render } from '@testing-library/react-native'; import HomeScreen from './screens/index';
describe('HomeScreen Component', () => {
it('renders HomeScreen with the welcome message', () => {
// Render the HomeScreen component
const { getByText } = render(
// Check if the Header and the welcome message are displayed
expect(getByText(/welcome message placeholder/i)).toBeTruthy();
});
});
Explanation
RootLayout Test: This test verifies if RootLayout renders child components correctly. We render RootLayout with HomeScreen as its child, then check if the welcome message from HomeScreen is present, confirming the layout is applied.
HomeScreen Test: This test validates the HomeScreen content specifically, ensuring components like the header and welcome message are rendered as expected.
These tests will verify that both your layout and home screen components are functioning properly in terms of rendering and structure. Let me know if you need more complex assertions or additional cases!
Thank you for the context on your setup with the RootLayout component and the HomeScreen component within a stack structure in the Expo-based React Native application. Below, I'll outline a Jest test case for both layout.tsx and index.tsx (HomeScreen) files, ensuring the tests validate the basic rendering and structure of these components.
Jest Test for RootLayout Component (layout.tsx)
This test case will check if the RootLayout component renders the expected stack layout and displays child content correctly.
import React from 'react'; import { render } from '@testing-library/react-native'; import RootLayout from './layout'; import HomeScreen from './screens/index';
describe('RootLayout Component', () => { it('renders RootLayout with child component', () => { // Render RootLayout with a sample child component const { getByText } = render(
);
// Check if HomeScreen content is rendered within the layout
expect(getByText(/welcome message placeholder/i)).toBeTruthy();
});
});
Jest Test for HomeScreen Component (index.tsx)
For HomeScreen, this test will validate the rendering of components like the VStack, Card, and Header from your layout setup.
import React from 'react'; import { render } from '@testing-library/react-native'; import HomeScreen from './screens/index';
describe('HomeScreen Component', () => {
it('renders HomeScreen with the welcome message', () => {
// Render the HomeScreen component
const { getByText } = render(
// Check if the Header and the welcome message are displayed
expect(getByText(/welcome message placeholder/i)).toBeTruthy();
});
});
Explanation
RootLayout Test: This test verifies if RootLayout renders child components correctly. We render RootLayout with HomeScreen as its child, then check if the welcome message from HomeScreen is present, confirming the layout is applied.
HomeScreen Test: This test validates the HomeScreen content specifically, ensuring components like the header and welcome message are rendered as expected.
These tests will verify that both your layout and home screen components are functioning properly in terms of rendering and structure. Let me know if you need more complex assertions or additional cases!
Using jest-expo as a preset is typically suitable for React Native projects as it simplifies Jest configuration for Expo apps. However, you might still encounter syntax issues or type errors, especially when certain imports or syntax are not handled correctly by default. Here are some additional steps you can try to resolve the error:
Ensure that you have the latest compatible versions of jest-expo, Babel, and related packages:
npm install --save-dev jest-expo @babel/core @babel/preset-env
With jest-expo, certain React Native modules might need to be explicitly transformed. In your package.json or jest.config.js, adjust the transformIgnorePatterns to handle necessary packages:
"jest": { "preset": "jest-expo", "transformIgnorePatterns": [ "node_modules/(?!(react-native|@react-native|react-navigation|my-project)/)" ] }
Replace "my-project" with any specific modules that need transformation.
In some cases, adding the following configuration to your babel.config.js can help Jest handle newer syntax:
module.exports = { presets: ['babel-preset-expo'], };
If you’re using custom Babel settings, make sure they don’t conflict with jest-expo.
Double-check the import path and syntax for ErrorHandler. Ensure that it’s a valid import and doesn’t cause conflicts in the test environment. You could temporarily comment it out to see if the error persists, helping to isolate the issue.
Sometimes, Jest’s cache can hold onto outdated configurations or code. Clear the cache by running:
npx jest --clearCache
After making these changes, try running the tests again. The jest-expo preset generally handles most Expo and React Native configurations, so if issues persist, it might be due to specific syntax or type compatibility within the code itself. Let me know if you need further assistance!
Using jest-expo as a preset is typically suitable for React Native projects as it simplifies Jest configuration for Expo apps. However, you might still encounter syntax issues or type errors, especially when certain imports or syntax are not handled correctly by default. Here are some additional steps you can try to resolve the error:
Ensure that you have the latest compatible versions of jest-expo, Babel, and related packages:
npm install --save-dev jest-expo @babel/core @babel/preset-env
With jest-expo, certain React Native modules might need to be explicitly transformed. In your package.json or jest.config.js, adjust the transformIgnorePatterns to handle necessary packages:
"jest": { "preset": "jest-expo", "transformIgnorePatterns": [ "node_modules/(?!(react-native|@react-native|react-navigation|my-project)/)" ] }
Replace "my-project" with any specific modules that need transformation.
In some cases, adding the following configuration to your babel.config.js can help Jest handle newer syntax:
module.exports = { presets: ['babel-preset-expo'], };
If you’re using custom Babel settings, make sure they don’t conflict with jest-expo.
Double-check the import path and syntax for ErrorHandler. Ensure that it’s a valid import and doesn’t cause conflicts in the test environment. You could temporarily comment it out to see if the error persists, helping to isolate the issue.
Sometimes, Jest’s cache can hold onto outdated configurations or code. Clear the cache by running:
npx jest --clearCache
After making these changes, try running the tests again. The jest-expo preset generally handles most Expo and React Native configurations, so if issues persist, it might be due to specific syntax or type compatibility within the code itself. Let me know if you need further assistance!
module.exports = { presets: [ 'module:metro-react-native-babel-preset', [ '@babel/preset-env', { targets: { node: 'current', }, }, ], ], plugins: [ '@babel/plugin-proposal-class-properties', [ '@babel/plugin-transform-runtime', { corejs: 3, helpers: true, regenerator: true, useESModules: false, }, ], ], };
module.exports = { presets: [ [ '@babel/preset-env', { targets: '>0.2%, not dead, not op_mini all', useBuiltIns: 'entry', // or 'usage' for automatic inclusion based on code usage corejs: 3, }, ], '@babel/preset-react', // For JSX in React applications ], };
module.exports = { presets: [ [ '@babel/preset-env', { targets: '>0.2%, not dead, not op_mini all', useBuiltIns: 'entry', // or 'usage' for automatic inclusion based on code usage corejs: 3, }, ], '@babel/preset-react', // For JSX in React applications ], };
module.exports = { presets: [ 'babel-preset-expo', '@babel/preset-env', // Ensure compatibility with Jest '@babel/preset-typescript', // For TypeScript support '@babel/preset-react' // For JSX support in React applications ], plugins: [ 'react-native-reanimated/plugin' // If you’re using Reanimated ], env: { test: { presets: [ [ '@babel/preset-env', { targets: { node: 'current' }, // Set target to Node for Jest }, ], '@babel/preset-typescript', ], }, }, };
module.exports = { presets: [ 'babel-preset-expo', '@babel/preset-env', // Ensure compatibility with Jest '@babel/preset-typescript', // For TypeScript support '@babel/preset-react' // For JSX support in React applications ], plugins: [ 'react-native-reanimated/plugin' // If you’re using Reanimated ], env: { test: { presets: [ [ '@babel/preset-env', { targets: { node: 'current' }, // Set target to Node for Jest }, ], '@babel/preset-typescript', ], }, }, };
{ "jest": { "preset": "react-native", "transform": { "^.+\.jsx?$": "babel-jest", "^.+\.tsx?$": "babel-jest" }, "transformIgnorePatterns": [ "node_modules/(?!(react-native|react-native-js-polyfills|@react-native|@expo)/)" ] } }
{ "jest": { "preset": "react-native", "transform": { "^.+\.jsx?$": "babel-jest", "^.+\.tsx?$": "babel-jest" }, "transformIgnorePatterns": [ "node_modules/(?!(react-native|react-native-js-polyfills|@react-native|@expo)/)" ] } }
moduleNameMapper: {
'^@compound-ui/(.*)$': '
Sure! Here is a step-by-step guide with the detailed code to resolve the issue with Jest failing to run tests for your React Native/Expo components due to native module dependencies and fbBatchedBridgeConfig errors.
Step 1: Create a Jest Setup File
In the root of your project (or in the apps/dashboard directory if you're working within a monorepo setup), create a new file named jestSetup.js. This file will contain the necessary mocks and configurations for Jest to handle React Native and platform-specific components.
Inside jestSetup.js, add the following code:
// jestSetup.js
// Mocking React Native's Native Modules jest.mock('react-native', () => { const ReactNative = jest.requireActual('react-native'); return { ...ReactNative, NativeModules: { ...ReactNative.NativeModules, fbBatchedBridge: { config: () => ({}), // Mock fbBatchedBridge to prevent errors }, }, }; });
// Mocking specific modules that rely on native functionality from gluestack-ui jest.mock('@gluestack-ui/toast', () => ({ ToastProvider: ({ children }) => children, // Provide a basic mock for ToastProvider }));
jest.mock('@gluestack-ui/overlay', () => ({ OverlayProvider: ({ children }) => children, // Provide a basic mock for OverlayProvider }));
// Additional mocks for other gluestack-ui or native modules can go here as needed
Step 2: Configure Jest to Use the Setup File
Open your jest.config.js (or package.json if Jest configuration is defined there).
Add setupFiles to include the jestSetup.js file, so Jest loads it before running any tests.
If using jest.config.js:
// jest.config.js
module.exports = {
preset: "react-native",
setupFiles: ["
If using package.json:
// package.json
{
"jest": {
"preset": "react-native",
"setupFiles": ["
Step 3: Install Jest Presets and Mock Packages (if needed)
To ensure Jest handles React Native components correctly, you may need to install jest-expo (for Expo projects) or the react-native/jest-preset.
Run one of the following commands based on your project setup:
For Expo projects:
pnpm add -D jest-expo
For React Native projects:
pnpm add -D jest react-native jest-preset-react-native
Step 4: Verify and Adjust Mocks as Needed
You may need to mock additional native modules or platform-specific components depending on the components used in your code. Add more mocks in jestSetup.js if you encounter other errors with native modules.
For example, if you’re using AsyncStorage, you can mock it like this:
// jestSetup.js jest.mock('@react-native-async-storage/async-storage', () => ({ getItem: jest.fn(), setItem: jest.fn(), }));
Step 5: Run Jest Tests
With these configurations in place, you can now run your Jest tests without encountering the fbBatchedBridgeConfig error.
Run your tests with:
pnpm test
This setup should allow Jest to mock native modules effectively and prevent errors related to fbBatchedBridgeConfig or other native dependencies.
Summary
The following files should now have the following content:
jestSetup.js:
// jestSetup.js
// Mocking React Native's Native Modules jest.mock('react-native', () => { const ReactNative = jest.requireActual('react-native'); return { ...ReactNative, NativeModules: { ...ReactNative.NativeModules, fbBatchedBridge: { config: () => ({}), // Mock fbBatchedBridge to prevent errors }, }, }; });
// Mocking specific modules from gluestack-ui that rely on native functionality jest.mock('@gluestack-ui/toast', () => ({ ToastProvider: ({ children }) => children, // Provide a basic mock for ToastProvider }));
jest.mock('@gluestack-ui/overlay', () => ({ OverlayProvider: ({ children }) => children, // Provide a basic mock for OverlayProvider }));
jest.config.js (or Jest configuration in package.json):
// jest.config.js
module.exports = {
preset: "react-native", // Use react-native preset
setupFiles: ["
These steps should help you resolve the Jest errors and allow you to test your components smoothly. Let me know if you have any further questions or encounter additional issues!
Sure! Here is a step-by-step guide with the detailed code to resolve the issue with Jest failing to run tests for your React Native/Expo components due to native module dependencies and fbBatchedBridgeConfig errors.
Step 1: Create a Jest Setup File
In the root of your project (or in the apps/dashboard directory if you're working within a monorepo setup), create a new file named jestSetup.js. This file will contain the necessary mocks and configurations for Jest to handle React Native and platform-specific components.
Inside jestSetup.js, add the following code:
// jestSetup.js
// Mocking React Native's Native Modules jest.mock('react-native', () => { const ReactNative = jest.requireActual('react-native'); return { ...ReactNative, NativeModules: { ...ReactNative.NativeModules, fbBatchedBridge: { config: () => ({}), // Mock fbBatchedBridge to prevent errors }, }, }; });
// Mocking specific modules that rely on native functionality from gluestack-ui jest.mock('@gluestack-ui/toast', () => ({ ToastProvider: ({ children }) => children, // Provide a basic mock for ToastProvider }));
jest.mock('@gluestack-ui/overlay', () => ({ OverlayProvider: ({ children }) => children, // Provide a basic mock for OverlayProvider }));
// Additional mocks for other gluestack-ui or native modules can go here as needed
Step 2: Configure Jest to Use the Setup File
Open your jest.config.js (or package.json if Jest configuration is defined there).
Add setupFiles to include the jestSetup.js file, so Jest loads it before running any tests.
If using jest.config.js:
// jest.config.js
module.exports = {
preset: "react-native",
setupFiles: ["
If using package.json:
// package.json
{
"jest": {
"preset": "react-native",
"setupFiles": ["
Step 3: Install Jest Presets and Mock Packages (if needed)
To ensure Jest handles React Native components correctly, you may need to install jest-expo (for Expo projects) or the react-native/jest-preset.
Run one of the following commands based on your project setup:
For Expo projects:
pnpm add -D jest-expo
For React Native projects:
pnpm add -D jest react-native jest-preset-react-native
Step 4: Verify and Adjust Mocks as Needed
You may need to mock additional native modules or platform-specific components depending on the components used in your code. Add more mocks in jestSetup.js if you encounter other errors with native modules.
For example, if you’re using AsyncStorage, you can mock it like this:
// jestSetup.js jest.mock('@react-native-async-storage/async-storage', () => ({ getItem: jest.fn(), setItem: jest.fn(), }));
Step 5: Run Jest Tests
With these configurations in place, you can now run your Jest tests without encountering the fbBatchedBridgeConfig error.
Run your tests with:
pnpm test
This setup should allow Jest to mock native modules effectively and prevent errors related to fbBatchedBridgeConfig or other native dependencies.
Summary
The following files should now have the following content:
jestSetup.js:
// jestSetup.js
// Mocking React Native's Native Modules jest.mock('react-native', () => { const ReactNative = jest.requireActual('react-native'); return { ...ReactNative, NativeModules: { ...ReactNative.NativeModules, fbBatchedBridge: { config: () => ({}), // Mock fbBatchedBridge to prevent errors }, }, }; });
// Mocking specific modules from gluestack-ui that rely on native functionality jest.mock('@gluestack-ui/toast', () => ({ ToastProvider: ({ children }) => children, // Provide a basic mock for ToastProvider }));
jest.mock('@gluestack-ui/overlay', () => ({ OverlayProvider: ({ children }) => children, // Provide a basic mock for OverlayProvider }));
jest.config.js (or Jest configuration in package.json):
// jest.config.js
module.exports = {
preset: "react-native", // Use react-native preset
setupFiles: ["
These steps should help you resolve the Jest errors and allow you to test your components smoothly. Let me know if you have any further questions or encounter additional issues!
Thank you for clarifying. Since your preset is jest-expo, here’s how you can set up Jest with the correct configurations. jest-expo is specifically designed for testing Expo projects, so it has unique setup requirements that slightly differ from react-native projects.
Updated Steps and Code
npm install --save-dev jest-expo @testing-library/react-native
{
"jest": {
"preset": "jest-expo",
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?@?react-native|@?expo(nent)?|@unimodules|unimodules))"
],
"moduleNameMapper": {
"^@compound-ui/(.*)$": "
Explanation:
"preset": "jest-expo": Uses the jest-expo preset, which is optimized for Expo projects.
"transformIgnorePatterns": This pattern ensures Expo’s dependencies and certain React Native dependencies are transformed correctly.
"moduleNameMapper": This mapping directs Jest to the correct paths for your @compound-ui components.
"setupFiles": Points to a setup file that we’ll create in the next step.
import "react-native-gesture-handler/jestSetup";
// Mock reanimated jest.mock("react-native-reanimated", () => require("react-native-reanimated/mock"));
// Mock other native modules as necessary jest.mock("expo-constants", () => ({ manifest: { extra: { apiUrl: "https://example.com" } } }));
jest.mock("expo-status-bar", () => ({ StatusBar: () => null }));
Explanation:
This setup file handles some commonly used Expo and React Native modules that may require mocking or setup to prevent errors during testing.
npm test
Additional Notes
If you still encounter module resolution issues, ensure that:
The paths in moduleNameMapper are correct.
Any other native modules used specifically by Expo are either mocked in jest.setup.js or configured appropriately.
This setup should provide a more tailored configuration for Expo, making use of jest-expo while ensuring paths and native modules are handled correctly. Let me know if there’s anything specific you’d like to focus on!
// babel.config.js
module.exports = {
// The presets
array is used to specify transformations for different languages and environments.
presets: [
'@babel/preset-expo', // Ensures compatibility with Expo's React Native environment.
'@babel/preset-typescript', // Adds support for TypeScript, allowing TypeScript code to be transpiled to JavaScript.
'@babel/preset-react', // Enables support for JSX, the syntax used by React for rendering components.
],
// The env
configuration allows for different settings based on the environment.
// Here, we define a test
environment for Jest, a testing framework.
env: {
test: {
presets: [
[
'@babel/preset-env', // Enables Babel to transform JavaScript based on the Node.js version used by Jest.
{
targets: { node: 'current' }, // Ensures compatibility with the current version of Node for Jest tests.
},
],
// Note: We don't need @babel/preset-typescript
here again, as it's already included in the global presets.
],
},
},
};
// babel.config.js
module.exports = {
// The presets
array is used to specify transformations for different languages and environments.
presets: [
'@babel/preset-expo', // Ensures compatibility with Expo's React Native environment.
'@babel/preset-typescript', // Adds support for TypeScript, allowing TypeScript code to be transpiled to JavaScript.
'@babel/preset-react', // Enables support for JSX, the syntax used by React for rendering components.
],
// The env
configuration allows for different settings based on the environment.
// Here, we define a test
environment for Jest, a testing framework.
env: {
test: {
presets: [
[
'@babel/preset-env', // Enables Babel to transform JavaScript based on the Node.js version used by Jest.
{
targets: { node: 'current' }, // Ensures compatibility with the current version of Node for Jest tests.
},
],
// Note: We don't need @babel/preset-typescript
here again, as it's already included in the global presets.
],
},
},
};
Pull Request Title:
Integrate New Dashboard Application into CI Pipeline with Jest Testing, Coverage Reporting, and ESLint/Prettier Support
Pull Request Description:
This PR introduces the Dashboard application, a new web-focused app built with React Native and supported by the Expo framework, into our monorepository. The PR includes the following updates:
Builds all applications, including the new Dashboard app.
Runs all test cases using the Jest framework.
Collects coverage reports with Jest and uploads them to an S3 bucket.
Integrates code formatting with Prisma and updates ESLint configurations to support the Dashboard app.
Applies necessary changes for Prettier and ESLint compliance across the project.
Modifies package.json to introduce required test libraries and Jest dependencies.
Updates the Babel configuration to set appropriate presets, ensuring smooth compilation.
This PR enhances our CI pipeline and maintains code quality standards for the new Dashboard application.
Subject: Follow-up on EMPRAPP-151 Status for CI Pipeline Integration
Hi Subhash,
I hope you're doing well. I wanted to check in on the current status of EMPRAPP-151 ("Use web output = static for dashboard app"), as it’s a prerequisite for moving forward with the CI pipeline integration for the dashboard (EMBER-392).
If there are any updates or additional context around the issue, please let me know. I’m looking forward to proceeding with the CI pipeline work once this dependency is resolved.
Thank you for your help, and please let me know if there’s anything I can assist with to expedite the process.
Best regards, [Your Name]