Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
/**
* `ngx-reactome-cytoscape-style` can be imported under vitest.
*
* Its published ESM does `import { isArray } from 'lodash'`, and lodash is
* CommonJS only. Vite's interop rejects that named import -- "Named export
* 'isArray' not found" -- before any test using the library can run.
* `server.deps.inline` in vitest.config.ts makes vite transform the library and
* resolve the interop, which is why that option is there.
*
* Nothing exercised it. Every module importing this library is a component, and
* the same config file explains that components are covered by e2e rather than
* unit tests -- so the option was load-bearing and untested, and a vitest or vite
* upgrade could have silently stopped honouring it. Found while moving to
* vitest 4 (#234), where it would have been exactly the kind of breakage a
* "244 passed" run does not mention.
*
* The import is the test. The assertions are here so it fails as a statement
* about the library rather than as a bare module error.
* It used to import lodash, which is CommonJS only, and vite's interop rejected
* the named import ("Named export 'isArray' not found") until vitest.config.ts
* inlined the library. The library no longer imports lodash
* (reactome/ngx-reactome-base#15), so that option is gone. This keeps the import
* under test, so a library build that brings back a CommonJS-only import fails
* here, as a statement about the library, rather than in whichever spec happens
* to pull it in first.
*/
import { describe, expect, it } from 'vitest';
import { ReactomeEventTypes, Style } from 'ngx-reactome-cytoscape-style';

describe('the cytoscape style library under vitest', () => {
it('imports, despite its lodash interop', () => {
it('imports under vitest as it is installed', () => {
expect(typeof Style, 'Style should be the class the diagram builds on').toBe('function');
});

Expand Down
3 changes: 1 addition & 2 deletions projects/pathway-browser/src/app/services/ehld.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { computed, ElementRef, Injectable, InjectionToken, inject } from '@angul
import { Observable, switchMap } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import type { Analysis } from '../model/analysis.model';
import { isArray } from 'lodash';
import { AnalysisService } from './analysis.service';
import { DataStateService } from './data-state.service';
import { UrlStateService } from './url-state.service';
Expand Down Expand Up @@ -337,7 +336,7 @@ export class EhldService {
const palette = type === 'fdr' ? this.analysis.fdrPalette() : this.analysis.palette();
values.forEach((exp, _i) => {
const last = stops.at(-1);
const realExp = isArray(exp) ? exp[0] : exp;
const realExp = Array.isArray(exp) ? exp[0] : exp;
if (last && last.exp === realExp) {
last.stop += delta;
last.width += delta;
Expand Down
18 changes: 0 additions & 18 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,5 @@ export default defineConfig({
// sat in the repo without being run by anything at all.
include: ['{src,projects,tools}/**/*.spec.{ts,mjs}'],
css: false,
// ngx-reactome-cytoscape-style's ESM does `import { isArray } from
// 'lodash'`, and lodash is CommonJS only, so vite's interop rejects the named
// import ("Named export 'isArray' not found") before any test touching the
// library can run. Inlining it makes vite transform the library and resolve
// the interop.
//
// The library is installed built, from ngx-reactome-base, so a local run and
// CI resolve the same copy. (When it was built here, a machine with dist/
// passed without this option and CI failed on four spec files.)
//
// diagram/cytoscape-style-interop.spec.ts imports the library directly, so
// this is covered by a test rather than only by whichever spec happens to
// pull the library in first.
server: {
deps: {
inline: [/reactome-cytoscape-style/],
},
},
},
});
Loading