@websolutespa/test 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/index.ts +149 -0
  3. package/package.json +44 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @websolutespa/test
2
+
3
+ ## 0.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: first release.
package/index.ts ADDED
@@ -0,0 +1,149 @@
1
+ import { Config } from 'jest';
2
+ import nextJest from 'next/jest';
3
+
4
+ const createJestConfig = nextJest({
5
+ // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
6
+ dir: './',
7
+ });
8
+
9
+ export const baseConfig: Config = {
10
+ verbose: false,
11
+ silent: false,
12
+ testTimeout: process.env.CI ? 20000 : 10000,
13
+ // testEnvironment: 'jsdom',
14
+ testEnvironment: 'jest-environment-jsdom',
15
+ // setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
16
+ reporters: ['default', 'github-actions'],
17
+ /*
18
+ snapshotFormat: {
19
+ printBasicPrototype: false,
20
+ },
21
+ */
22
+ /*
23
+ coverageThreshold: {
24
+ global: {
25
+ branches: 80,
26
+ functions: 80,
27
+ lines: 80,
28
+ statements: 80,
29
+ }
30
+ },
31
+ */
32
+ coverageReporters: ['html', 'text', 'text-summary', 'lcov'],
33
+ };
34
+
35
+ export function getProjectConfig(): {} {
36
+ const cwd = process.cwd();
37
+ // console.log('getProjectConfig', 'process.cwd()', cwd);
38
+ const config: Config = {
39
+ ...baseConfig,
40
+ rootDir: '.',
41
+ roots: [
42
+ `${cwd}`,
43
+ ],
44
+ resetMocks: true,
45
+ modulePaths: [
46
+ `${cwd}/src/`,
47
+ ],
48
+ moduleDirectories: [
49
+ 'node_modules',
50
+ ],
51
+ testMatch: [
52
+ '<rootDir>/src/**/*(?<!e2e).test.{js,jsx,ts,tsx}',
53
+ ],
54
+ coverageDirectory: `${cwd}/coverage`,
55
+ collectCoverageFrom: [
56
+ '<rootDir>/src/**/*(?<!test).{js,jsx,ts,tsx}',
57
+ ],
58
+ setupFilesAfterEnv: [`${cwd}/jest.setup.js`],
59
+ transform: {
60
+ '^.+\\.(ts|tsx)?$': ['@swc/jest', {
61
+ jsc: {
62
+ transform: {
63
+ react: {
64
+ runtime: 'automatic',
65
+ },
66
+ },
67
+ },
68
+ }]
69
+ },
70
+ // Rewrite Swiper ESM imports as paths (allows them to be transformed w/o errors)
71
+ moduleNameMapper: {
72
+ '\\.(css|scss)$': 'identity-obj-proxy',
73
+ '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/src/packages/test/jest.mock.file.js',
74
+ // swiper
75
+ 'swiper': '<rootDir>/node_modules/swiper/swiper-bundle.js',
76
+ 'swiper/react': '<rootDir>/node_modules/swiper/react/swiper-react.js',
77
+ // 'swiper/css': '<rootDir>/node_modules/swiper/swiper.min.css',
78
+ // 'swiper/css/bundle': '<rootDir>/node_modules/swiper/swiper-bundle.min.css',
79
+ // 'swiper/css/autoplay': '<rootDir>/node_modules/swiper/modules/autoplay/autoplay.min.css',
80
+ // 'swiper/css/free-mode': '<rootDir>/node_modules/swiper/modules/autoplay/free-mode.min.css',
81
+ // 'swiper/css/navigation': '<rootDir>/node_modules/swiper/modules/autoplay/navigation.min.css',
82
+ // 'swiper/css/pagination': '<rootDir>/node_modules/swiper/modules/autoplay/pagination.min.css',
83
+ // Handle module aliases (this will be automatically configured for you soon)
84
+ // '^@/components/(.*)$': '<rootDir>/components/$1',
85
+ // '^@/pages/(.*)$': '<rootDir>/pages/$1',
86
+ },
87
+ transformIgnorePatterns: [
88
+ 'node_modules',
89
+ 'node_modules/(?!(swiper|swiper/react|ssr-window|dom7)/)',
90
+ ]
91
+ };
92
+ return config;
93
+ }
94
+
95
+ export function getAppConfig(): {} {
96
+ const config: Config = getProjectConfig();
97
+ config.transform = {
98
+ '^.+\\.(ts|tsx)?$': ['@swc/jest', {
99
+ jsc: {
100
+ transform: {
101
+ react: {
102
+ runtime: 'automatic',
103
+ },
104
+ },
105
+ },
106
+ tsconfig: 'tsconfig.test.json'
107
+ }]
108
+ };
109
+ return createJestConfig(config);
110
+ }
111
+
112
+ export function getPackageConfig(): {} {
113
+ const cwd = process.cwd();
114
+ // console.log('getPackageConfig', 'process.cwd()', cwd);
115
+ const config: Config = {
116
+ ...baseConfig,
117
+ rootDir: '.',
118
+ roots: [
119
+ `${cwd}`,
120
+ ],
121
+ modulePaths: [
122
+ `${cwd}/src/`,
123
+ ],
124
+ moduleDirectories: [
125
+ 'node_modules',
126
+ ],
127
+ testMatch: [
128
+ '<rootDir>/src/**/*(?<!e2e).test.{js,jsx,ts,tsx}',
129
+ ],
130
+ coverageDirectory: `${cwd}/coverage`,
131
+ collectCoverageFrom: [
132
+ '<rootDir>/src/**/*(?<!test).{js,jsx,ts,tsx}',
133
+ ],
134
+ transform: {
135
+ '^.+\\.(ts|tsx)?$': ['@swc/jest', {
136
+ jsc: {
137
+ transform: {
138
+ react: {
139
+ runtime: 'automatic',
140
+ },
141
+ },
142
+ },
143
+ }]
144
+ },
145
+ transformIgnorePatterns: ['node_modules'],
146
+ };
147
+ // console.log('getPackageConfig', config);
148
+ return config;
149
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@websolutespa/test",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "keywords": [
6
+ "bom",
7
+ "test"
8
+ ],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git://github.com/websolutespa/bom.git"
13
+ },
14
+ "main": "index.ts",
15
+ "types": "index.ts",
16
+ "sideEffects": false,
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "scripts": {
21
+ "lint": "eslint *.js*"
22
+ },
23
+ "dependencies": {
24
+ "eslint-config-websolute": "*"
25
+ },
26
+ "devDependencies": {
27
+ "@playwright/test": "^1.29.1",
28
+ "@testing-library/dom": "^8.19.0",
29
+ "@testing-library/jest-dom": "^5.16.5",
30
+ "@testing-library/react": "^13.4.0",
31
+ "@testing-library/user-event": "^14.4.3",
32
+ "@types/jest": "^29.2.4",
33
+ "identity-obj-proxy": "^3.0.0",
34
+ "jest-environment-jsdom": "^29.3.1",
35
+ "jest-fail-on-console": "^3.0.2",
36
+ "jest-matcher-utils": "^29.3.1",
37
+ "jest": "^29.3.1",
38
+ "npm-run-all": "^4.1.5",
39
+ "open-cli": "^7.1.0",
40
+ "ts-node": "^10.9.1",
41
+ "tsup": "^6.6.3",
42
+ "typescript": "^4.8.2"
43
+ }
44
+ }