Skip to content

Commit

Permalink
test: ng add set skipLibCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
boeckMt committed May 16, 2022
1 parent cfe3da9 commit 5f146b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions projects/core-ui/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ function ruleUpdateTsConfigFile(): Rule {
json.compilerOptions.paths[p.name] = p.paths;
}

// skipLibCheck for libraries like OpenLayers
if (!json.compilerOptions.skipLibCheck) {
json.compilerOptions.skipLibCheck = true;
}

return json;
});
};
Expand Down
27 changes: 18 additions & 9 deletions projects/core-ui/schematics/ng-add/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Schema as WorkspaceOptions } from '@schematics/angular/workspace/schema
import { Schema as ApplicationOptions, Style } from '@schematics/angular/application/schema';
import { UkisNgAddSchema } from './schema';
import * as path from 'path';
import { TsconfigJSON } from '../schema.tsconfig';


const collectionPath = require.resolve(path.join(__dirname, '../collection.json'));
Expand Down Expand Up @@ -169,15 +170,23 @@ describe('ng-add', () => {

it('should update the tsconfig file', async () => {
const tree = await schematicRunner.runSchematicAsync('ng-add', ngAddOptions, appTree).toPromise();
const tsconfigFilePath = '/tsconfig.json';
const baseTsconfigFilePath = '/tsconfig.base.json';
if (tree.exists(baseTsconfigFilePath)) {
const tsconfigFile = JSON.parse(tree.readContent(baseTsconfigFilePath));
expect('@dlr-eoc/*' in tsconfigFile.compilerOptions.paths).toBe(true);
} else {
const tsconfigFile = JSON.parse(tree.readContent(tsconfigFilePath));
expect('@dlr-eoc/*' in tsconfigFile.compilerOptions.paths).toBe(true);
}
const configs = ['/tsconfig.json', '/tsconfig.base.json'];
configs.forEach(configFilePath => {
if (tree.exists(configFilePath)) {
const tsconfigFile = JSON.parse(tree.readContent(configFilePath)) as TsconfigJSON;
const paths = tsconfigFile?.compilerOptions?.paths;
expect(paths).toBeTruthy();
if (paths) {
expect('@dlr-eoc/*' in paths).toBe(true);
}

const skipLibCheck = tsconfigFile?.compilerOptions?.skipLibCheck;
expect(skipLibCheck).toBeTruthy();
if (skipLibCheck !== undefined) {
expect(skipLibCheck).toBe(true);
}
}
});
});

it('should update html files', async () => {
Expand Down

0 comments on commit 5f146b4

Please sign in to comment.