mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge pull request #14148 from meteor/test-eager-fixes
[Rspack] Eager test ignores relative to the project path and expand ignore test coverage
This commit is contained in:
@@ -117,7 +117,7 @@ function createIgnoreRegex(globPatterns) {
|
||||
|
||||
// For absolute paths, we don't want to force the pattern to match from the beginning
|
||||
// but we still want to ensure it matches to the end of the path segment
|
||||
regexPattern = '(?:^|/)' + regexPattern + '$';
|
||||
regexPattern = '(?:^|/)' + regexPattern;
|
||||
|
||||
return regexPattern;
|
||||
}).filter(pattern => pattern !== null);
|
||||
|
||||
@@ -9,6 +9,7 @@ const { createIgnoreRegex, createIgnoreGlobConfig } = require("./ignore.js");
|
||||
* @param {string} options.projectDir - The project directory
|
||||
* @param {string} options.buildContext - The build context
|
||||
* @param {string[]} options.ignoreEntries - Array of ignore patterns
|
||||
* @param {string[]} options.meteorIgnoreEntries - Array of meteor ignore patterns
|
||||
* @param {string} options.extraEntry - Extra entry to load
|
||||
* @returns {string} The path to the generated file
|
||||
*/
|
||||
@@ -17,6 +18,7 @@ const generateEagerTestFile = ({
|
||||
projectDir,
|
||||
buildContext,
|
||||
ignoreEntries: inIgnoreEntries = [],
|
||||
meteorIgnoreEntries: inMeteorIgnoreEntries = [],
|
||||
prefix: inPrefix = '',
|
||||
extraEntry,
|
||||
globalImportPath,
|
||||
@@ -40,6 +42,11 @@ const generateEagerTestFile = ({
|
||||
const excludeFoldersRegex = createIgnoreRegex(
|
||||
createIgnoreGlobConfig(ignoreEntries)
|
||||
);
|
||||
console.log("inMeteorIgnoreEntries", inMeteorIgnoreEntries);
|
||||
// Create regex from meteor ignore entries
|
||||
const excludeMeteorIgnoreRegex = inMeteorIgnoreEntries.length > 0
|
||||
? createIgnoreRegex(createIgnoreGlobConfig(inMeteorIgnoreEntries))
|
||||
: null;
|
||||
|
||||
const prefix = (inPrefix && `${inPrefix}-`) || "";
|
||||
const filename = isAppTest
|
||||
@@ -51,15 +58,27 @@ const generateEagerTestFile = ({
|
||||
: "/\\.(?:test|spec)s?\\.[^.]+$/";
|
||||
|
||||
const content = `${
|
||||
globalImportPath ? `import '${globalImportPath}';\n\n` : ''
|
||||
}{
|
||||
const ctx = import.meta.webpackContext('/', {
|
||||
globalImportPath ? `import '${globalImportPath}';\n\n` : ""
|
||||
}${
|
||||
excludeMeteorIgnoreRegex
|
||||
? `const MeteorIgnoreRegex = ${excludeMeteorIgnoreRegex.toString()};`
|
||||
: ""
|
||||
}
|
||||
{
|
||||
const ctx = import.meta.webpackContext('${projectDir}', {
|
||||
recursive: true,
|
||||
regExp: ${regExp},
|
||||
exclude: ${excludeFoldersRegex.toString()},
|
||||
mode: 'eager',
|
||||
});
|
||||
ctx.keys().forEach(ctx);
|
||||
ctx.keys().filter((k) => {
|
||||
${
|
||||
excludeMeteorIgnoreRegex
|
||||
? `// Only exclude based on *relative* path segments.
|
||||
return !MeteorIgnoreRegex.test(k);`
|
||||
: "return true;"
|
||||
}
|
||||
}).forEach(ctx);
|
||||
${
|
||||
extraEntry
|
||||
? `const extra = import.meta.webpackContext('${path.dirname(
|
||||
|
||||
4
npm-packages/meteor-rspack/package-lock.json
generated
4
npm-packages/meteor-rspack/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@meteorjs/rspack",
|
||||
"version": "1.1.0-beta.2",
|
||||
"version": "1.1.0-beta.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@meteorjs/rspack",
|
||||
"version": "1.1.0-beta.2",
|
||||
"version": "1.1.0-beta.6",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@meteorjs/rspack",
|
||||
"version": "1.1.0-beta.2",
|
||||
"version": "1.1.0-beta.6",
|
||||
"description": "Configuration logic for using Rspack in Meteor projects",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
|
||||
@@ -434,7 +434,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
||||
isAppTest: true,
|
||||
projectDir,
|
||||
buildContext,
|
||||
ignoreEntries: [...meteorIgnoreEntries, "**/server/**"],
|
||||
ignoreEntries: ["**/server/**"],
|
||||
meteorIgnoreEntries,
|
||||
prefix: "client",
|
||||
extraEntry: path.resolve(process.cwd(), Meteor.mainClientEntry),
|
||||
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
||||
@@ -445,7 +446,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
||||
isClient: true,
|
||||
projectDir,
|
||||
buildContext,
|
||||
ignoreEntries: [...meteorIgnoreEntries, "**/server/**"],
|
||||
ignoreEntries: ["**/server/**"],
|
||||
meteorIgnoreEntries,
|
||||
prefix: "client",
|
||||
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
||||
})
|
||||
@@ -555,7 +557,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
||||
isAppTest: true,
|
||||
projectDir,
|
||||
buildContext,
|
||||
ignoreEntries: [...meteorIgnoreEntries, "**/client/**"],
|
||||
ignoreEntries: ["**/client/**"],
|
||||
meteorIgnoreEntries,
|
||||
prefix: "server",
|
||||
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
||||
})
|
||||
@@ -564,7 +567,8 @@ module.exports = async function (inMeteor = {}, argv = {}) {
|
||||
isAppTest: false,
|
||||
projectDir,
|
||||
buildContext,
|
||||
ignoreEntries: [...meteorIgnoreEntries, "**/client/**"],
|
||||
ignoreEntries: ["**/client/**"],
|
||||
meteorIgnoreEntries,
|
||||
prefix: "server",
|
||||
globalImportPath: path.resolve(projectDir, buildContext, entryPath),
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
export const DEFAULT_RSPACK_VERSION = '1.7.1';
|
||||
|
||||
export const DEFAULT_METEOR_RSPACK_VERSION = '1.1.0-beta.2';
|
||||
export const DEFAULT_METEOR_RSPACK_VERSION = '1.1.0-beta.6';
|
||||
|
||||
export const DEFAULT_METEOR_RSPACK_REACT_HMR_VERSION = '1.4.3';
|
||||
|
||||
|
||||
16
tools/modern-tests/apps/react-router/.meteorignore
Normal file
16
tools/modern-tests/apps/react-router/.meteorignore
Normal file
@@ -0,0 +1,16 @@
|
||||
# Folder combination patterns
|
||||
react-router*
|
||||
tests/ignored/react-router*-ignored
|
||||
tests/ignored/folder-to-ignored/
|
||||
tests/ignored/file-to-ignored.app-test.js
|
||||
**/glob-ignored/*.app-test.js
|
||||
tests/ignored/prefix-*-ignored
|
||||
tests/ignored/*-ignored-suffix
|
||||
|
||||
# File combination patterns
|
||||
tests/ignored/specific-file-ignored.app-test.js
|
||||
tests/ignored/*.temp-ignored.app-test.js
|
||||
**/unit/*.app-test.js
|
||||
tests/ignored/integration/*-ignored.app-test.js
|
||||
tests/ignored/test-*-ignored.app-test.js
|
||||
!important.app-test.js
|
||||
@@ -0,0 +1,7 @@
|
||||
import assert from "assert";
|
||||
|
||||
describe("!important.app-test.js pattern", () => {
|
||||
it("should run as it's not ignored (negation)", () => {
|
||||
assert(true, "should run");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("react-router*-ignored pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/file-to-ignored.app-test.js pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/folder-to-ignored/ pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/integration/*-ignored.app-test.js pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/prefix-*-ignored pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/react-router*-ignored pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/*-ignored-suffix pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/some/nested/glob-ignored/ignore.app-test.js pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/some/unit/test-ignored.app-test.js pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/specific-file-ignored.app-test.js pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/test-*-ignored.app-test.js pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
describe("tests/ignored/*.temp-ignored.app-test.js pattern", () => {
|
||||
it("should not run as ignored", () => {
|
||||
throw new Error("test should be ignored by eager test loading");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user