Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websmith addon testing api #43

Merged
merged 52 commits into from
May 9, 2024
Merged

Websmith addon testing api #43

merged 52 commits into from
May 9, 2024

Conversation

jwloka
Copy link
Member

@jwloka jwloka commented May 7, 2024

This PR proposes an initial APII for simplifying compiler testing significantly. Setup the typescript compiler, customize projects settings, add custom compiler addons, and compile various projects within 5 lines of code. Use Unit Test style setup and assertions with Jest. Compile projects from the filesystem or from virtual file content and compare compiled results expected from the filesystem, or virtual snapshots.

The library can run tests, with

  • Standard Jest test runner configuration and API
  • Compiler addons written in TypeScript directly (no need to compile them upfront)
  • A virtual file system, compile from and to memory, no need to write files to disk
  • Mixed project and addon sources from the filesystem and virtual file content
  • Navigate the project and compiled files with a simple API
  • Compare compiled file contents with expected from the filesystem, or virtual snapshots

See README.md for more details

@jwloka jwloka requested review from meck93 and maur-o May 7, 2024 10:02
@jwloka jwloka self-assigned this May 7, 2024
jwloka added 27 commits May 7, 2024 15:29
+ Support for virtual mode (everything in memory, no FS needed)
+ Add addons to the compilation from existing directory or from source string
+ Add project code to the compilation from existing directory or from source string
+ Remove need for fusion-fs in addon tests
…sults:

+ Add getCompiledFiles: returns all files in outDir
+ Add getCompiledFile: returns first matching file in outDir
+ Add getCompiledDir: returns absolute path to outDir
+ Add CompilationResults: with full access to the ts.EmitResult providing:
   * hasEmitSkipped: () => boolean;
   * getEmittedFiles: () => string[];
   * hasFailures: () => boolean;
   * getFailureReport: (filter?: string) => string;
   * getDiagnostics: () => ts.Diagnostic[];
+ Not all emitted files are added to ts.EmitResult
+ tsLibDefaults cannot be added  to file system, when browserSystem is used
Note: It'll be replaced with @quatico/webbloqs-testing
jwloka added 25 commits May 7, 2024 15:29
This is a major change in the AddonRegistry's lifecycle. No files are loaded upfront, no addons are compiled and activated in its constructor.

+ Don't read files initially, start with empty file system
+ Don't compile addons initially
+ Move AddonRegistry into the compiler as class property and provide a separate config parameter
+ Extend compile-system to configure and provide AddonRegistry separately
+ Remove addons from CompilerArguments
+ Add importDir as sourceFolder for addons to compile
@jwloka jwloka force-pushed the websmith-addon-testing-api branch from 61c46f9 to 4d7da05 Compare May 7, 2024 13:33
.npmrc Show resolved Hide resolved
@jwloka jwloka mentioned this pull request May 9, 2024
@jwloka jwloka merged commit fa0db82 into develop May 9, 2024
2 checks passed
@jwloka jwloka deleted the websmith-addon-testing-api branch May 9, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants