PhantomJS version 2.1.1 encountered an error on a Windows 7 system, displaying "ReferenceError: Map variable not found."

I've been utilizing the "MVC ASP.NET Core with Angular" template. I'm attempting to incorporate phantomJS and execute the tests, but encountering the following errors:

    ERROR in [at-loader] ..\\node_modules\zone.js\dist\zone.js.d.ts:122:11 TS2451: Cannot redeclare block-scoped variable 'Zone'. 

ERROR in [at-loader] ..\\node_modules\zone.js\ dist\zone.js.d.ts:363:14 TS2300: Duplicate identifier 'HasTaskState'. 

ERROR in [at-loader] ..\\node_modules\zone.js\ dist\zone.js.d.ts:372:14 TS2300: Duplicate identifier 'TaskType'. 

ERROR in [at-loader] ..\\node_modules\zone.js\ dist\zone.js.d.ts:458:15 TS2451: Cannot redeclare block-scoped variable 'Zone'.

PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR ReferenceError: Can't find variable: Map at ../wwwroot/dist/vendor.js:12460

Listing the versions of node modules from my package.json file:

"dependencies": {
    "@angular/animations": "4.1.2",
    "@angular/common": "4.1.2",
    ...
    "zone.js": "0.8.10"
  },
  "devDependencies": {
    "@types/chai": "3.5.2",
    ...
    "phantomjs-prebuilt": "^2.1.15"
  }
}`

Here is a snippet of my tsconfig.json:

`{
    "compilerOptions": {
        "moduleResolution": "node",
        ...
    },
    "exclude": [
        "bin",
        "node_modules"
    ],
    "atom": { "rewriteTsconfig": false }
}`

and the webpack.config.js that I'm using:

`const path = require('path');
const webpack = require('webpack');
...
};
`

Seeking guidance on resolving the aforementioned errors. Tried suggested solutions mentioned in https://github.com/monounity/karma-typescript/issues/83, but haven't found a solution yet.

Any assistance would be highly appreciated!

Anticipating a helpful response.

Thank you.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`` Solution for integrating chrome headless:

added "puppeteer" in dev dependencies in package.json.

Configured in Karma.config.js:

    const ChromiumRevision = require('puppeteer/package.json').puppeteer.chromium_revision;
const Downloader = require('puppeteer/utils/ChromiumDownloader');
const revisionInfo = Downloader.revisionInfo(Downloader.currentPlatform(), ChromiumRevision);


module.exports = function (config) {

     config.set({ ...

         browsers: ['ChromeHeadless'],
    ..
    });
};

Answer №1

When attempting to run tests with phantomJS, I encountered the following errors:

Despite efforts to make it work using core-js, PhantomJS is outdated and lacks support for ES6 features such as Map. It may be challenging to bring this obsolete technology up to modern standards.

Further Information

A recommended alternative to PhantomJS is Chrome Headless.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Nested promises utilized within functional programming techniques

Working on an Angular project involves developing a booking system with various scenarios. The challenge lies in handling different server calls based on the response of a promise, leading to a nested callback structure that contradicts the purpose of prom ...

Close button in Popover not functioning properly for SVG element

Concern I am facing an issue with a popover close button in this fiddle. The close button on the popover seems to work only once. Detailed Explanation My goal is to create SVG elements dynamically through Angular directives, and I want them to have Popo ...

What is the best way to ensure an observable has been updated before proceeding with additional code execution?

Is an observable the best choice for providing live updates of a variable's value to another class? I have a loop in my service class that looks like this: elements.forEach(element => { doStuff(); this.numberSubject.next(valueFromDoStuff); }) ...

`Could not locate JavaScript files within the _nuxt directory`

I encountered a strange issue with my Nuxt 2.15.4 project. While the code was functioning perfectly locally (<--dev & build-->), it fails to load correctly on the server after the build process. The error message I am seeing is: GET https://example.c ...

An unexpected error occurred in the file node_modules/@firebase/firestore/dist/index.d.ts at line 27:28 - Please insert a ']' at this location

When adding firebase to my Angular app, I encountered an error while running ng serve: ERROR in node_modules/@firebase/firestore/dist/index.d.ts:27:28 - error TS1005: ']' expected. 27 [K in keyof T & string as `${Prefix}.${K}`]+?: T[K]; ...

Create a function that will always output an array with the same number of elements as the input

Is there a method to generate a function that specifies "I accept an array of any type, and will return the same type with the same length"? interface FixedLengthArray<T, L extends number> extends Array<T> { length: L; } export function shuf ...

Enhancing the session object with new properties

I am attempting to include extra properties in the session object req.session.confirmationCode = confirmationCode; However, I encounter an error stating that the property confirmationCode does not exist Property 'confirmationCode' does not exist ...

The element event does not trigger an update on the view

I am trying to display the caret position of my editor on a specific place on the website. I have created a directive and service to share variables between the controller and directive. Inside the directive, I have enabled events like "keyup", "mouseup", ...

What is the solution for the warning "Solid's reactivity is broken when destructuring component props"?

Just starting out with SolidJS and encountering an issue with my UI setup import { render } from "solid-js/web"; import { createSignal, Show } from "solid-js"; import { createStore } from 'solid-js/store'; function Form() { ...

Arranging an array of arrays based on the mm/dd/yyyy date field

Currently, I am facing an issue while attempting to sort data obtained from an API by date in the client-side view. Here is an example of the data being received: address: "1212 Test Ave" address2: "" checkNumber : "" city: "La Grange" country: "" email: ...

Transcluding content inside a table cell with Angular

Recently, I came across a peculiar issue with an attribute directive in Angular. This directive simply adds a class name to the element where it is applied, specifically to a table cell <td>. Oddly enough, when I set transclude: true in the directive ...

Angular array of considerable size

Dealing with a massive array of 30,000 items can be quite daunting, especially when it comes in as a stream using grpc-web. Currently, I'm fetching the data from grpc.client() and populating an array before displaying it using *ngFor. However, I' ...

Is it possible to use square brackets in conjunction with the "this" keyword to access a class property using an expression?

export class AppComponent implements OnInit { userSubmitted = false; accountSubmitted = false; userForm!: FormGroup; ngOnInit(): void {} onSubmit(type: string): void { this[type + 'Submitted'] = true; if(this[type + 'For ...

Seems like the ng-show events inside are not being triggered, almost like an invisible image

I am encountering an issue where no JavaScript events are triggering inside an ng-show div in my code. You can access my code through the following link on Plnkr: http://plnkr.co/edit/kGqk8x?p=preview Upon loading data from JSON, I set ng-show to true. Ho ...

Dealing with Memory Leaks in AngularJS and Jquery

My web application has been created with a combination of jQuery and Angularjs. I am currently on the lookout for patterns that could lead to memory leaks in Angularjs. I have used Chrome profiler as a tool to find memory leaks, but unfortunately haven&a ...

Mastering Props Typing in React Using TypeScript

Currently, I am faced with the task of defining the following: interface MyCompProps { someAttr: number } Instead of having to explicitly list all the aria-* attributes I need upfront, I would like to simply use aria- and other normal HTML attributes ...

What is the best way to perform type checking for a basic generic function without resorting to using a cumbersome cast

Struggling with TypeScript and trying to understand a specific issue for the past few days. Here is a simplified version: type StrKeyStrVal = { [key: string]: string }; function setKeyVal<T extends StrKeyStrVal>(obj: T, key: keyof T, value: str ...

Tips for updating collection-repeat list when a value is modified

On my view, I have a collection-repeat element displaying a large amount of data, and I want to dynamically change its sorting based on the user's selection from a dropdown menu. Even though the $scope.isAscending variable is being updated correctly, ...

The type inference in TypeScript sometimes struggles to accurately determine the type of an iterable

Struggling to get TypeScript to correctly infer the underlying iterable type for the function spread. The purpose of this function is to take an iterable of iterable types, infer the type of the underlying iterable, and return a new iterable with that infe ...

Enhance the step implementation in Cucumber-js

Background In my TypeScript project, I am utilizing https://github.com/cucumber/cucumber-js. The code snippet below showcases a typical cucumber implementation: import { Given, Then, When } from 'cucumber' Given(`Page is up and run ...