Skip to content

Commit

Permalink
chore: remove logs from tests (#5361)
Browse files Browse the repository at this point in the history
* chore: update test

* chore: keep dep warnings
  • Loading branch information
h-a-n-a authored Jan 18, 2024
1 parent b2282a1 commit 8ba4b9c
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/rspack-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "tsc -b ./tsconfig.build.json",
"dev": "tsc -b -w",
"test": "cross-env RSPACK_DEP_WARNINGS=false jest --runInBand"
"test": "cross-env jest --runInBand"
},
"files": [
"bin",
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build:viewer": "rspack build",
"dev:viewer": "rspack serve",
"dev": "tsc -b -w",
"test:diff": "cross-env RSPACK_DIFF=true NO_COLOR=1 RSPACK_DEP_WARNINGS=false node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --runInBand --logHeapUsage --testPathPattern \".diff.test.ts\""
"test:diff": "cross-env RSPACK_DIFF=true NO_COLOR=1 node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --runInBand --logHeapUsage --testPathPattern \".diff.test.ts\""
},
"files": [
"client",
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"build": "tsc -b ./tsconfig.build.json",
"dev": "tsc -w",
"test": "cross-env NO_COLOR=1 RSPACK_DEP_WARNINGS=false node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --testPathIgnorePatterns \".diff.test.ts\" --runInBand --logHeapUsage"
"test": "cross-env NO_COLOR=1 node --expose-gc --max-old-space-size=8192 --experimental-vm-modules ../../node_modules/jest-cli/bin/jest --testPathIgnorePatterns \".diff.test.ts\" --runInBand --logHeapUsage"
},
"files": [
"dist"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Container } from "./Button";
import { Container as Container2 } from './Button2'
import { Container as Container2 } from "./Button2";

it("styled components", () => {
console.log(Container.componentStyle);
expect(Container.displayName).toMatch("Button__Container");
expect(Container.styledComponentId).toMatch(
/^Button__Container-rspack-test__/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const fs = require("fs");

console.debug("test-console");
console.log("test-console");
console.warn("test-console");
console.error("test-console");
globalThis.__logger = {
debug() {},
log() {},
warn() {},
error() {}
};
__logger.debug("test-console");
__logger.log("test-console");
__logger.warn("test-console");
__logger.error("test-console");

function getTestLogLevels(content) {
const regex = /console\.(\S+?)\("test-console"/g;
const regex = /__logger\.(\S+?)\("test-console"/g;
const logs = [];
while ((array1 = regex.exec(content)) !== null) {
logs.push(array1[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
minimize: true,
minimizer: [
new rspack.SwcJsMinimizerRspackPlugin({
pureFuncs: ["console.error", "console.warn"]
pureFuncs: ["__logger.error", "__logger.warn"]
})
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Plugin {

resolveData.request = `${request}.js`;

console.log(resolveData);
// console.log(resolveData);
}

return undefined;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const lib = require("./lib");
it("minify-plugin", () => {
console.log("lib:", lib);
// console.log("lib:", lib);
expect(lib.answer).toEqual(42);
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const fs = require("fs");

console.debug("test-console");
console.log("test-console");
console.warn("test-console");
console.error("test-console");
globalThis.__logger = {
debug() {},
log() {},
warn() {},
error() {}
};
__logger.debug("test-console");
__logger.log("test-console");
__logger.warn("test-console");
__logger.error("test-console");

function getTestLogLevels(content) {
const regex = /console\.(\S+?)\("test-console"/g;
const regex = /__logger\.(\S+?)\("test-console"/g;
const logs = [];
while ((array1 = regex.exec(content)) !== null) {
logs.push(array1[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
plugins: [
new rspack.SwcJsMinimizerRspackPlugin({
compress: {
pure_funcs: ["console.error", "console.warn"]
pure_funcs: ["__logger.error", "__logger.warn"]
}
})
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
console.log(42);
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
console.log(42);
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ it("css-simple", () => {
expect(fs.existsSync(path.resolve(__dirname, "./foo_js.css"))).toBe(true);
expect(fs.existsSync(path.resolve(__dirname, "./main.css"))).toBe(true);
});

console.log(__dirname);
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import _ from "lodash";
console.log(_.VERSION);
eval(_);
1 change: 0 additions & 1 deletion scripts/debug/launch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export async function launchJestWithArgs(additionalArgs) {
args,
env: {
NO_COLOR: JSON.stringify(1),
RSPACK_DEP_WARNINGS: JSON.stringify(false),
...process.env
},
cwd: process.cwd()
Expand Down

This file was deleted.

1 comment on commit 8ba4b9c

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

name base current %
10000_development-mode + exec 1.65 s ± 18 ms 1.66 s ± 13 ms +0.84%
10000_development-mode_hmr + exec 994 ms ± 9.6 ms 998 ms ± 12 ms +0.44%
10000_production-mode + exec 2.7 s ± 26 ms 2.75 s ± 56 ms +1.81%
threejs_development-mode_10x + exec 2.01 s ± 17 ms 2.02 s ± 18 ms +0.47%
threejs_development-mode_10x_hmr + exec 1.32 s ± 13 ms 1.32 s ± 5.8 ms +0.14%
threejs_production-mode_10x + exec 5.93 s ± 24 ms 5.91 s ± 26 ms -0.19%

Please sign in to comment.