# Test runs ok from webstorm, but fails as nx test lib in terminal

## SYMPTOMS

The test in question was related to the `rxjs` code below:

```typescript
this.allStartTimes$ = this.store.select(selectAllCheckedCountersValues).pipe(
  map(countersValues => {
    const allValues = countersValues
      .map(counterValues => counterValues.values)
      .flat()
      .map(value => value.startTime);

    return sortedUniq(allValues.sort());
  })
);
```

The tests were failing with generic `TypeError`, after adding catchError in related observables, the following error was shown:

```text
TypeError: countersValues.map(...).flat is not a function
```

Which is weird because it is a legit array function and this case runs from webstorm `Run` button no prob.

## FIX

This is a known issue in ts-jest, adding core-js to test setup fixes the issue, [as described here](https://github.com/kulshekhar/ts-jest/issues/828).

Weird how it works in webstorm though. In this case, I couldn't add core-js to test setup, so the workaround was to use `flatten` from lodash instead of `array.flat()`.

```typescript
this.allStartTimes$ = this.store.select(selectAllCheckedCountersValues).pipe(
  map(countersValues => {
    const allValues: Value[][] = countersValues.map(
      counterValues => counterValues.values
    );
    const allTimestamps: string[] = flatten(allValues).map(
      (value: Value) => value.startTime
    );

    return sortedUniq(allTimestamps.sort());
  })
);
```