From 6ea6c4a43718914df311909832b9d8fc79241b35 Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Wed, 15 Jan 2025 15:05:52 +0100 Subject: [PATCH 1/3] chore: remove integration tests --- .github/workflows/main-suite.yml | 3 -- .github/workflows/release.yml | 3 -- CONTRIBUTING.md | 82 ++++++++++++++++---------------- jest.config.integration.js | 17 ------- package.json | 3 +- 5 files changed, 43 insertions(+), 65 deletions(-) delete mode 100644 jest.config.integration.js diff --git a/.github/workflows/main-suite.yml b/.github/workflows/main-suite.yml index a244c85d1..d83a0ac14 100644 --- a/.github/workflows/main-suite.yml +++ b/.github/workflows/main-suite.yml @@ -74,9 +74,6 @@ jobs: - name: Test Public Typings run: yarn test:tsd - - name: Integration Testing - run: yarn test:integration - - name: E2E Testing run: yarn test:e2e diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efd87c0f9..a464566c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,9 +41,6 @@ jobs: - name: Linting & Types run: yarn lint:all - - name: Integration Testing - run: yarn test:integration - - name: Creates local .npmrc run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b97a5d867..48f5e544a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ This project and everyone participating in it are governed by the [Code of Condu The documentation is based on [Docusaurus](https://docusaurus.io/) framework. Source inside the [website](https://github.com/lingui/js-lingui/tree/main/website) directory. -- Go to the `website` directory: +- Go to the `website` directory: ```sh cd website @@ -20,24 +20,24 @@ The documentation is based on [Docusaurus](https://docusaurus.io/) framework. So - Install dependencies: - ```sh - yarn install - ``` + ```sh + yarn install + ``` - To build the docs, watch for changes and preview documentation locally at [http://localhost:3000/](http://localhost:3000/): - ```sh - yarn start - ``` + ```sh + yarn start + ``` - It's also possible to run `yarn build` for single build. Incremental builds are much faster than the first one as only changed files are built. - Please lint and validate the documentation before submitting any changes: - ```sh - yarn lint - yarn checkFormat - ``` + ```sh + yarn lint + yarn checkFormat + ``` ## Contributing the code @@ -68,10 +68,6 @@ This project uses [yarn][yarninstall] package manager. Please follow [official][ yarn test ``` - > **Note** - > If you are using an IDE to run test make sure to use the right Jest config. - > For unit tests use `-c jest.config.js`. Integration tests use build packages (created using `yarn release:build`) and config `-c jest.config.integration.js`. See [package.json](./package.json) for more info. - ### Using development version in your project After you successfully fix a bug or add a new feature, you most probably want to test it in a real-world project as soon as possible. @@ -84,44 +80,50 @@ There are two documented ways to do this: first is a generic way described in th 1. Run `verdaccio` locally in docker (follow [verdaccio guide](https://verdaccio.org/docs/en/what-is-verdaccio.html) if you don't want to run it in Docker): - ```sh - docker run -d -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio - ``` + ```sh + docker run -d -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio + ``` - > Make sure that your verdaccio user is the same that appears in verdacio-release.js script. + > Make sure that your verdaccio user is the same that appears in verdacio-release.js script. 2. Publish local build of packages to registry. Run local release script: - ```sh - yarn verdaccio:release - ``` + ```sh + yarn verdaccio:release + ``` 3. If you enter inside http://0.0.0.0:4873 (verdaccio instance), you will see your packages published, so you're ready to install them. 4. Inside your project, run: - with NPM: - ```sh - # Point to your local registry - npm config set registry http://0.0.0.0:4873/ - # Run update-by-scope will update all @lingui packages - npx update-by-scope @lingui - ``` - with Yarn Classic (1.*): - ```sh - yarn upgrade --scope @lingui --registry http://0.0.0.0:4873/ --latest - ``` - with Yarn Berry: - ```sh - YARN_NPM_REGISTRY_SERVER=http://0.0.0.0:4873/ yarn up "@lingui/*" - ``` + with NPM: + + ```sh + # Point to your local registry + npm config set registry http://0.0.0.0:4873/ + # Run update-by-scope will update all @lingui packages + npx update-by-scope @lingui + ``` + + with Yarn Classic (1.\*): + + ```sh + yarn upgrade --scope @lingui --registry http://0.0.0.0:4873/ --latest + ``` + + with Yarn Berry: + + ```sh + YARN_NPM_REGISTRY_SERVER=http://0.0.0.0:4873/ yarn up "@lingui/*" + ``` + 5. After you make some changes, you need to run the same process. (Releasing + yarn upgrade) 6. When finished testing, restore default registry (only for NPM) - ```sh - npm config set registry https://registry.npmjs.org/ - ``` + ```sh + npm config set registry https://registry.npmjs.org/ + ``` #### Testing changes using the React Native example diff --git a/jest.config.integration.js b/jest.config.integration.js deleted file mode 100644 index a914bda82..000000000 --- a/jest.config.integration.js +++ /dev/null @@ -1,17 +0,0 @@ -const sourceConfig = require("./jest.config") - -/** - * @type {import('jest').Config} - */ -module.exports = { - ...sourceConfig, - projects: sourceConfig.projects.map((project) => ({ - ...project, - // Redirect imports to the compiled bundles. - // This is to test compiled code instead of source (applies to code under test and also its deps). - moduleNameMapper: {}, - })), - - // Exclude the build output from transforms - transformIgnorePatterns: ["/node_modules/", "/packages/*/build/"], -} diff --git a/package.json b/package.json index edb451308..4b9e398ce 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,9 @@ "test": "jest", "test:ci": "jest --ci --runInBand", "test:ci:coverage": "yarn test:ci --coverage", - "test:integration": "yarn node --experimental-vm-modules $(yarn bin jest) -c jest.config.integration.js", "test:e2e": "yarn workspaces foreach -p run test:e2e", "test:tsd": "jest -c jest.config.types.js", - "test:all": "yarn test && yarn test:integration && yarn test:e2e && yarn test:tsd", + "test:all": "yarn test && yarn test:e2e && yarn test:tsd", "lint:types": "tsc", "lint:eslint": "eslint ./packages", "lint:all": "yarn lint:eslint && yarn lint:types", From f12123d390e07e671b643945e23c8ac12e2135ab Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Thu, 16 Jan 2025 11:54:43 +0100 Subject: [PATCH 2/3] set type for a labeled expression --- packages/core/macro/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/macro/index.d.ts b/packages/core/macro/index.d.ts index 8559e0279..8a26aa185 100644 --- a/packages/core/macro/index.d.ts +++ b/packages/core/macro/index.d.ts @@ -232,4 +232,4 @@ export const msg: typeof defineMessage /** * Helps to define a name for a variable in the message */ -export function ph(def: LabeledExpression): string +export function ph(def: LabeledExpression): string From 33d97f831f8358a36f598f84e58e1033feb15f2e Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Thu, 16 Jan 2025 12:05:42 +0100 Subject: [PATCH 3/3] skip vite tests on windows, because they are flaky --- packages/vite-plugin/test/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vite-plugin/test/index.ts b/packages/vite-plugin/test/index.ts index 3ec6c4bff..8a333df23 100644 --- a/packages/vite-plugin/test/index.ts +++ b/packages/vite-plugin/test/index.ts @@ -2,8 +2,11 @@ import path from "path" import { exec as _exec } from "child_process" import { mkdtempSync } from "fs" import os from "os" +import { platform } from "node:os" -describe("vite-plugin", () => { +const skipOnWindows = platform() === "win32" ? describe.skip : describe + +skipOnWindows("vite-plugin", () => { it("should return compiled catalog", async () => { const mod = await runVite(`po-format/vite.config.ts`) expect((await mod.load()).messages).toMatchSnapshot()