Skip to content

Commit

Permalink
feat: fl infra frontendTesting
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed May 19, 2024
1 parent 8d747d9 commit 1ff4765
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
enable_bundlewatch: <%= modules.bundlewatch %>
enable_prettier: <%= modules.prettier %>
enable_typescript: <%= modules.typescript %>
enable_tests: <%= modules.frontendTesting %>

frontend_directory: <%= params.frontendDirectory %>
backend_directory: <%= params.backendDirectory %>
Expand Down
1 change: 1 addition & 0 deletions boilerplate/skeleton/extension/js/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@flarum/jest-config')({});
5 changes: 4 additions & 1 deletion boilerplate/skeleton/extension/js/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "@<%= params.packageName %>",
"private": true,
"type": "module",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
},
"devDependencies": {
"@flarum/jest-config": "^2.0.0",
"@flarum/prettier-config": "^1.0.0",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^3.0.0",
Expand All @@ -25,6 +27,7 @@
"build-typings": "<%= params.jsPackageManager %> run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && <%= params.jsPackageManager %> run post-build-typings",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'",
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report"
"check-typings-coverage": "typescript-coverage-report",
"test": "yarn node --experimental-vm-modules $(yarn bin jest)"
}
}
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions boilerplate/skeleton/extension/js/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"include": ["tests/**/*"],
"files": ["../../../node_modules/@flarum/jest-config/shims.d.ts"],
"compilerOptions": {
"strict": false,
"noImplicitReturns": false,
"noImplicitAny": false
}
}
29 changes: 29 additions & 0 deletions src/steps/gen-ext-scaffolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export const EXTENSION_MODULES = [
'prettier',
'typescript',
'bundlewatch',
'frontendTesting',

'backendTesting',
'phpstan',
Expand Down Expand Up @@ -605,6 +606,34 @@ function moduleNameToDef(name: ExtensionModules): Module<ExtensionModules> {
},
};

case 'frontendTesting':
return {
name,
updatable: true,
togglable: true,
defaultEnabled: true,
shortDescription: 'Frontend testing via Jest and Mithril Query.',
dependsOn: ['js'],
filesToReplace: [
'js/jest.config.cjs',
'js/tsconfig.test.json',
'js/webpack.config.cjs',
'js/tests/unit/.gitkeep',
'js/tests/integration/.gitkeep',
],
jsonToAugment: {
'js/package.json': [
'devDependencies.@flarum/jest-config',
'scripts.test',
'type',
],
},
needsTemplateParams: [],
inferEnabled: async (_fs, paths: Paths) => {
return existsSync(paths.package('js/jest.config.cjs'));
},
};

case 'backendTesting':
return {
name,
Expand Down

0 comments on commit 1ff4765

Please sign in to comment.