Skip to content

Commit

Permalink
Project update. [p][robotic]
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswrks committed Aug 30, 2023
1 parent 08b0fab commit fded47f
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 316 deletions.
1 change: 1 addition & 0 deletions dev/.files/madrun/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default async (/* {cmd, args, ctx} */) => {
'build': async ({ args }) => 'npx vite build' + (args.mode ? '' : ' --mode=prod') + ' {{@}}',

'tests': async ({ args }) => 'npx vitest' + (args.mode ? '' : ' --mode=dev') + ' {{@}}',
'tests:sandbox': async ({ args }) => 'VITEST_SANDBOX_ENABLE=true npx vitest' + (args.mode ? '' : ' --mode=dev') + ' {{@}}',
'tests:ui': async ({ args }) => 'npx vitest --watch --ui' + (args.mode ? '' : ' --mode=dev') + ' {{@}}',

'jest': 'npx jest {{@}}', // Runs project Jest tests.
Expand Down
45 changes: 31 additions & 14 deletions dev/.files/vite/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default async ({ mode, command, ssrBuild: isSSRBuild }) => {
const useMinifier = 'dev' !== mode && !['lib'].includes(appType);
const preserveModules = ['lib'].includes(appType) && appEntries.length > 1;
const useUMD = !isSSRBuild && !targetEnvIsServer && !preserveModules && !peerDepKeys.length && useLibMode && 1 === appEntries.length;
const vitestSandboxEnable = $str.parseValue(String(process.env.VITEST_SANDBOX_ENABLE || '')); // We invented this environment variable.

/**
* Validates all of the above.
Expand Down Expand Up @@ -500,20 +501,37 @@ export default async ({ mode, command, ssrBuild: isSSRBuild }) => {
'**/node_modules/**',
'**/jspm_packages/**',
'**/bower_components/**',
'**/{x-*}/**', // Deliberate exclusions.
...(vitestSandboxEnable ? [] : ['**/sandbox/**']),
'**/*.d.{ts,tsx,cts,ctsx,mts,mtsx}',
];
const vitestIncludes = [
'**/*.{test,tests,spec,specs}.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
'**/{test,tests,spec,specs,__test__,__tests__,__spec__,__specs__}/**/*.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
];
const vitestTypecheckIncludes = [
'**/*.{test,tests,spec,specs}-d.{ts,tsx,cts,ctsx,mts,mtsx}', //
'**/{test,tests,spec,specs,__test__,__tests__,__spec__,__specs__}/**/*-d.{ts,tsx,cts,ctsx,mts,mtsx}',
];
const vitestBenchIncludes = [
'**/*.{bench,benchmark,benchmarks}.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
'**/{bench,benchmark,benchmarks,__bench__,__benchmark__,__benchmarks__}/**/*.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
];
const vitestIncludes = vitestSandboxEnable
? [
'**/sandbox/**/*.{test,tests,spec,specs}.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
'**/{test,tests,spec,specs,__test__,__tests__,__spec__,__specs__}/**/sandbox/**/*.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
]
: [
'**/*.{test,tests,spec,specs}.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
'**/{test,tests,spec,specs,__test__,__tests__,__spec__,__specs__}/**/*.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
];
const vitestTypecheckIncludes = vitestSandboxEnable
? [
'**/sandbox/**/*.{test,tests,spec,specs}-d.{ts,tsx,cts,ctsx,mts,mtsx}', //
'**/{test,tests,spec,specs,__test__,__tests__,__spec__,__specs__}/**/sandbox/**/*-d.{ts,tsx,cts,ctsx,mts,mtsx}',
]
: [
'**/*.{test,tests,spec,specs}-d.{ts,tsx,cts,ctsx,mts,mtsx}', //
'**/{test,tests,spec,specs,__test__,__tests__,__spec__,__specs__}/**/*-d.{ts,tsx,cts,ctsx,mts,mtsx}',
];
const vitestBenchIncludes = vitestSandboxEnable
? [
'**/sandbox/**/*.{bench,benchmark,benchmarks}.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
'**/{bench,benchmark,benchmarks,__bench__,__benchmark__,__benchmarks__}/**/sandbox/**/*.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
]
: [
'**/*.{bench,benchmark,benchmarks}.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
'**/{bench,benchmark,benchmarks,__bench__,__benchmark__,__benchmarks__}/**/*.{js,jsx,cjs,cjsx,node,mjs,mjsx,ts,tsx,cts,ctsx,mts,mtsx}',
];
const vitestExtensions = ['.js', '.jsx', '.cjs', '.cjsx', '.json', '.node', '.mjs', '.mjsx', '.ts', '.tsx', '.cts', '.ctsx', '.mts', '.mtsx'];

const vitestConfig = {
Expand All @@ -529,8 +547,7 @@ export default async ({ mode, command, ssrBuild: isSSRBuild }) => {
unstubEnvs: true, // Remove all env stubs before a test begins.
unstubGlobals: true, // Remove all global stubs before a test begins.

// @todo Enhance web worker support.
// @todo Fix and enhance miniflare support.
// @todo Implement web worker support. No DOM in web workers.
environment: ['cfp', 'web', 'webw'].includes(targetEnv) ? 'jsdom' // <https://o5p.me/Gf9Cy5>.
: ['cfw'].includes(targetEnv) ? 'miniflare' // <https://o5p.me/TyF9Ot>.
: ['node', 'any'].includes(targetEnv) ? 'node' // <https://o5p.me/Gf9Cy5>.
Expand Down
Loading

0 comments on commit fded47f

Please sign in to comment.