Skip to content
This repository has been archived by the owner on Dec 3, 2022. It is now read-only.

Jasmine 4.0.1 does not work with jasmine-ts #177

Closed
air2 opened this issue Jan 6, 2022 · 7 comments
Closed

Jasmine 4.0.1 does not work with jasmine-ts #177

air2 opened this issue Jan 6, 2022 · 7 comments

Comments

@air2
Copy link

air2 commented Jan 6, 2022

When I upgrade to Jasmine 4.0.1 I get the following error:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/command' is not defined by "exports" in C:\projects\myProject\service\node_modules\jasmine\package.json
    at new NodeError (internal/errors.js:322:7)
    at throwExportsNotFound (internal/modules/esm/resolve.js:322:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:545:3)
    at resolveExports (internal/modules/cjs/loader.js:450:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\projects\myProject\service\node_modules\@cspotcode\source-map-support\source-map-support.js:679:30)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
@ert78gb
Copy link
Collaborator

ert78gb commented Jan 7, 2022

Jasmine 4 has many breaking changes. Have to work on the compatibility

@ert78gb
Copy link
Collaborator

ert78gb commented Jan 9, 2022

I think this library is outdated and generates more problems than solves.

Jasmine@4 does not expose jasmine/lib/command and I could agree with it. Jasmine@4 also started to support ES6 module but currently it does not support custom module loader. Therefore the ts-node/esm loader has to be set to NODE_OPTIONS environment variables in order to be able to load the transpiled typescript code.

The loader is to be set before the node process starts. Otherwise this helper library has to start a new node process. But I think it is an overkill and gives an extra complexity to the jasmine, typescript and ts-node config management and debugging process.

I think it is more clear if we use proper jasmine configuration, so I have created 2 example projects to demonstrate how to setup jasmine@4, typescript with commonjs and ES6 module resolution.

@air2
Copy link
Author

air2 commented Jan 19, 2022

Sorry for my late response, but your 2 examples really helped me to remove the jasmine-ts dependency. Thank u

@air2 air2 closed this as completed Jan 19, 2022
mardanbeigi added a commit to mardanbeigi/PrettyScribe that referenced this issue Feb 6, 2022
Update most packages, including webpack to v5. To make sure live reloads for dev mode works, tell the devserver to write files to disk.

The "expected" webpack workflow is to have webpack know about every file that's part of the build, including CSS, images, and HTML. Then, the devserver bundles all of these together and provides mangled names for each file.

Prettyscribe doesn't currently link all its files together in a way that makes webpack happy. I tried turning links into imports that webpack can manage, but that change is bigger and more complex.

Side note, jasmine package is still on the older v3, since v4 doesn't support jasmine-ts. Soln for that is in svi3c/jasmine-ts#177 (comment), but on first pass I couldn't get it to work.
mardanbeigi added a commit to mardanbeigi/PrettyScribe that referenced this issue Feb 8, 2022
Update Jasmine to v4, and update package-lock.json to latest version since a bunch of other deps were recently updated.

Drop jasmine-ts dep (it doesn't work with jasmine v4) and follow suggestion from svi3c/jasmine-ts#177 (comment) to get TypeScript files working.

TIL package-lock.json is supposed to be committed to the repo: https://nodejs.dev/learn/the-package-lock-json-file
@pushkin-
Copy link

pushkin- commented Apr 20, 2022

@ert78gb Not sure if I'm doing something wrong, but I tried your commonjs example and still get:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath '[./lib/command]()' is not defined by "exports" in [C:\<somepath>\node_modules\jasmine\package.json]()
    at new NodeError (node:internal/errors:371:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:731:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] ([C:\<somepath>\node_modules\]()@cspotcode\source-map-support\source-map-support.js:679:30)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

when running unit tests

My guess is that it's not picking up my helper script.

@ert78gb
Copy link
Collaborator

ert78gb commented Apr 20, 2022

Hi, The example perfectly works for me. If I upgrade every dependency to the latest stable then it still works.

Are you sure did you setup everything correctly?

@pushkin-
Copy link

@ert78gb yeah I followed everything exactly. This is my jasmine.json:

{
	"spec_dir": "./src/**/specs",
	"spec_files": [
		"**/*[sS]pec.ts"
	],
	"helpers": [
		"jasmine-typescript-helper.js"
	]
}

Even when I delete spec_dir and spec_files, I get the error. Maybe the relative helper path is wrong?

@ert78gb
Copy link
Collaborator

ert78gb commented Apr 20, 2022

In my example I don't use source-map-support Maybe it is miss configured somehow.
I tested with WebStorm/IntelliJ and VSCode Insider and the debugging works without any issue. The debugger stops in the source and spec files too.

In WebStorm I open the package.json and I click on the small play icon before the test script.

In VsCode Insider I use the Debug npm Script commad.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants