Error with react-intl While Running Cypress Tests After Upgrading to Vite 4.0.0

After upgrading from Webpack 4 to Vite 4.0.0 and updating react-intl to version 6.5.5, our Cypress tests are failing with the following error message:

Error: The following error originated from your application code, not from Cypress.

> [@formatjs/intl] An `id` must be provided to format a message. You can either:
1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.io/docs/tooling/babel-plugin)
or [@formatjs/ts-transformer](https://formatjs.io/docs/tooling/ts-transformer) OR
2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.io/docs/tooling/linter#enforce-id)
to autofix this issue

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

this is how my lang.json file looks

{
"id": "message",
}

eg

{
"++9ROC": "Hello welcome to stack overflow",
}

Context
Vite Version: ^4.0.0
react-intl Version: ^6.5.5
Cypress Version: 12.17.3
cypress-vite Version: ^1.5.0

The error appears to be originating from the react-intl library, specifically from the formatMessage function. It suggests that an id must be provided to format a message and provides two potential solutions involving configuration changes to the build toolchain or ESLint.

I think cypress is using webpack somewhere and not vite even though I have specified in my cypress.config.js file

cypress config :

module.exports = defineConfig({
    component: {
        fixturesFolder: false,
        video: false,
        viewportWidth: 1920,
        viewportHeight: 1080,
        retries: {
            runMode: 4,
            openMode: 0,
        },
        defaultCommandTimeout: 20000,
        devServer: {
            framework: 'react',
            bundler: 'vite',
        },
        specPattern: 'src/**/__tests__/**/*.cypress.jsx',
        setupNodeEvents(on, config) {
            coverage(on, config);
            return config;
        },
    },
});

.babelrc file

plugins: [
    react({
        include: '@aap/**/*.{js,jsx}',
        babel: {
            babelrcRoots: '@aap/**',
            babelrc: true,
        },
    }),
    injectDefinitions({ presets, mode, buildEnv, skipPreset }),
    vitePluginRequire(),
    splitVendorChunkPlugin(),
    Inspect(),
    viteCompression(),
],

vite.config.js plugin config

plugins: [
            react({
                include: '@aap/**/*.{js,jsx}',
                babel: {
                    babelrcRoots: '@aap/**',
                    babelrc: true,
                },
            }),
            // commonjs(),
            injectDefinitions({ presets, mode, buildEnv, skipPreset }),
            vitePluginRequire(),
            splitVendorChunkPlugin(),
            Inspect(),
            viteCompression(),
        ],

I am looking for guidance on how to resolve this issue in the context of using Vite and Cypress. Specifically, I would like to know:

How to properly configure Vite to work with babel-plugin-formatjs or @formatjs/ts-transformer to ensure id is automatically provided for react-intl messages.

Any necessary changes to the Cypress configuration or setup to accommodate these changes.

Best practices for integrating these tools together to avoid similar issues in the future.

Any detailed steps or examples on how to implement these solutions would be greatly appreciated.

New contributor

ashutosh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật