angular/packages/localize/tools/test/helpers/index.ts
Paul Gschwendtner a18981ab7b refactor: move localize/src/tools into localize/tools folder (#43431)
Moves the `src/tools` folder of the `@angular/localize` package into the
top-level of the package. This is in preparation of actually exposing an
entry-point for the tools that can be accessed using
`@angular/localize/tools`.

We want to expose such an entry-point because the CLI currently
deep-imports into various places of the tools, but this will not
work well with strict ESM because the localize tool depends on the
v13 strict ESM packages like the `@angular/compiler` or
`@angular/compiler-cli`.

PR Close #43431
2021-10-01 18:28:44 +00:00

25 lines
1,007 B
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {setFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system';
import {InvalidFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system/src/invalid_file_system';
import {MockFileSystemNative} from '@angular/compiler-cli/src/ngtsc/file_system/testing';
/**
* Only run these tests on the "native" file-system.
*
* Babel uses the `path.resolve()` function internally, which makes it very hard to mock out the
* file-system from the outside. We run these tests on Unix and Windows in our CI jobs, so there is
* test coverage.
*/
export function runInNativeFileSystem(callback: () => void) {
describe(`<<FileSystem: Native>>`, () => {
beforeEach(() => setFileSystem(new MockFileSystemNative()));
afterEach(() => setFileSystem(new InvalidFileSystem()));
callback();
});
}