Skip to content

Commit

Permalink
build: Setup test apps for upcoming snapshot tests (#17)
Browse files Browse the repository at this point in the history
Create some initial test apps for the upcoming snapshot tests.
  • Loading branch information
nicholas-codecov authored Dec 5, 2023
1 parent 0ba0d59 commit e224faf
Show file tree
Hide file tree
Showing 28 changed files with 774 additions and 375 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ const config = {
"**/coverage/**",
"**/dist/**",
"**/node_modules/**",
"**/test-apps/**",
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: __dirname,
project: [
"./tsconfig.json",
"./integration-tests/tsconfig.json",
"./packages/bundler-plugin-core/tsconfig.json",
"./packages/rollup-plugin/tsconfig.json",
"./packages/vite-plugin/tsconfig.json",
Expand Down
4 changes: 2 additions & 2 deletions bundlers/next-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-js",
"version": "0.1.0",
"name": "next-js-test",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
6 changes: 1 addition & 5 deletions bundlers/rollup/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "rollup",
"name": "rollup-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"dev": "npm-run-all --parallel start watch",
"start": "serve public"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@codecov/rollup-plugin": "workspace:^",
"date-fns": "^2.16.1"
Expand Down
4 changes: 2 additions & 2 deletions bundlers/vite/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vite",
"name": "vite-test",
"private": true,
"version": "0.0.0",
"type": "module",
Expand Down Expand Up @@ -33,4 +33,4 @@
"engines": {
"node": ">=18.0.0"
}
}
}
8 changes: 2 additions & 6 deletions bundlers/webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
{
"name": "webpack",
"version": "1.0.0",
"description": "",
"name": "webpack-test",
"version": "0.0.0",
"private": "true",
"scripts": {
"build": "webpack --config webpack.config.js"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
Expand Down
27 changes: 27 additions & 0 deletions integration-tests/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require("./package.json") as { version: string };

const config = {
testEnvironment: "node",
collectCoverageFrom: ["!**/node_modules/**"],
transform: {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
jsc: {
transform: {
optimizer: {
globals: {
vars: {
__PACKAGE_VERSION__: packageJson.version,
},
},
},
},
},
},
],
},
};

export default config;
24 changes: 24 additions & 0 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "integration-tests",
"version": "1.0.0",
"description": "",
"private": true,
"license": "MIT",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@swc/core": "^1.3.99",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.10",
"@types/node": "^20.10.3",
"jest": "^29.7.0",
"rollup": "4.6.0",
"ts-node": "^10.9.1",
"vite": "5.0.3",
"webpack": "5.89.0"
},
"volta": {
"extends": "../package.json"
}
}
23 changes: 23 additions & 0 deletions integration-tests/test-apps/rollup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "rollup",
"version": "1.0.0",
"private": true,
"license": "MIT",
"type": "module",
"scripts": {
"build": "rollup -c"
},
"dependencies": {
"@codecov/rollup-plugin": "workspace:^",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.1.0",
"lodash": "^4.17.21",
"rollup": "^4.6.1"
},
"volta": {
"extends": "../../../package.json"
},
"engines": {
"node": ">=18.0.0"
}
}
20 changes: 20 additions & 0 deletions integration-tests/test-apps/rollup/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import { codecovRollupPlugin } from "@codecov/rollup-plugin";
import { defineConfig } from "rollup";

export default defineConfig({
input: "src/main.js",
output: {
dir: "dist",
entryFileNames: "[name]-[hash].js",
},
plugins: [
resolve(),
commonjs(),
codecovRollupPlugin({
enableBundleAnalysis: true,
dryRun: true,
}),
],
});
3 changes: 3 additions & 0 deletions integration-tests/test-apps/rollup/src/getRandomNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
12 changes: 12 additions & 0 deletions integration-tests/test-apps/rollup/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import _ from "lodash";
import { getRandomNumber } from "./getRandomNumber.js";

const randomNumber = getRandomNumber(1, 10);

const output = `Is ${randomNumber} between 0 and 5: ${_.inRange(
randomNumber,
0,
5,
)}`;

console.log(randomNumber); // Outputs a random number between 1 and 10
13 changes: 13 additions & 0 deletions integration-tests/test-apps/vite/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions integration-tests/test-apps/vite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "vite",
"version": "1.0.0",
"private": true,
"license": "MIT",
"type": "module",
"scripts": {
"build": "vite build"
},
"dependencies": {
"@codecov/vite-plugin": "workspace:^",
"lodash": "^4.17.21",
"vite": "5.0.3"
},
"volta": {
"extends": "../../../package.json"
},
"engines": {
"node": ">=18.0.0"
}
}
3 changes: 3 additions & 0 deletions integration-tests/test-apps/vite/src/getRandomNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
12 changes: 12 additions & 0 deletions integration-tests/test-apps/vite/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import _ from "lodash";
import { getRandomNumber } from "./getRandomNumber.js";

const randomNumber = getRandomNumber(1, 10);

const output = `Is ${randomNumber} between 0 and 5: ${_.inRange(
randomNumber,
0,
5,
)}`;

console.log(randomNumber); // Outputs a random number between 1 and 10
11 changes: 11 additions & 0 deletions integration-tests/test-apps/vite/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "vite";
import { codecovVitePlugin } from "@codecov/vite-plugin";

export default defineConfig({
plugins: [
codecovVitePlugin({
enableBundleAnalysis: true,
dryRun: true,
}),
],
});
20 changes: 20 additions & 0 deletions integration-tests/test-apps/webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "webpack",
"version": "1.0.0",
"license": "MIT",
"type": "module",
"scripts": {
"build": "webpack --config webpack.config.cjs"
},
"dependencies": {
"@codecov/webpack-plugin": "workspace:^",
"lodash": "^4.17.21",
"webpack": "5.89.0"
},
"volta": {
"extends": "../../../package.json"
},
"engines": {
"node": ">=18.0.0"
}
}
3 changes: 3 additions & 0 deletions integration-tests/test-apps/webpack/src/getRandomNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
12 changes: 12 additions & 0 deletions integration-tests/test-apps/webpack/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import _ from "lodash";
import { getRandomNumber } from "./getRandomNumber.js";

const randomNumber = getRandomNumber(1, 10);

const output = `Is ${randomNumber} between 0 and 5: ${_.inRange(
randomNumber,
0,
5,
)}`;

console.log(randomNumber); // Outputs a random number between 1 and 10
17 changes: 17 additions & 0 deletions integration-tests/test-apps/webpack/webpack.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const path = require("path");
const { codecovWebpackPlugin } = require("@codecov/webpack-plugin");

module.exports = {
entry: "./src/main.js",
mode: "production",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].[contenthash].chunk.js",
},
plugins: [
codecovWebpackPlugin({
enableBundleAnalysis: true,
dryRun: true,
}),
],
};
5 changes: 5 additions & 0 deletions integration-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.json",
"include": ["jest.config.ts"],
"exclude": ["coverage/**/*", "node_modules/**/*", "./test-apps/**/*"]
}
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "bundle-stats-plugin",
"version": "1.0.0",
"description": "",
"main": "index.js",
"version": "0.0.0",
"description": "Codecov Bundler Plugins Monorepo",
"private": true,
"workspaces": [
"packages/*"
Expand All @@ -19,9 +18,6 @@
"test:unit:ci": "pnpm -r --filter='./packages/*' run test:unit:ci",
"prepare": "husky install"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@total-typescript/ts-reset": "^0.5.1",
"@types/eslint": "^8.44.7",
Expand Down
7 changes: 3 additions & 4 deletions packages/bundler-plugin-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "@codecov/bundler-plugin-core",
"version": "0.0.1",
"description": "",
"description": "Official Codecov Bundler Plugin Core",
"author": "Codecov",
"license": "MIT",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -33,9 +35,6 @@
"test:unit": "jest",
"test:unit:ci": "jest --coverage"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"dependencies": {
"chalk": "4.1.2",
"semver": "^7.5.4",
Expand Down
7 changes: 3 additions & 4 deletions packages/rollup-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "@codecov/rollup-plugin",
"version": "0.0.1",
"description": "",
"description": "Official Codecov Rollup plugin",
"author": "Codecov",
"license": "MIT",
"type": "module",
"exports": {
".": {
Expand Down Expand Up @@ -33,9 +35,6 @@
"test:unit": "jest",
"test:unit:ci": "jest --coverage"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@codecov/bundler-plugin-core": "workspace:^"
},
Expand Down
Loading

0 comments on commit e224faf

Please sign in to comment.