Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for webpack + ts #15

Merged
merged 1 commit into from
Nov 23, 2021

Conversation

blutorange
Copy link
Collaborator

I added a test that runs webpack on a simple index.ts that sets up a color picker, then loads a simple index.html via jsdom and checks whether the color picker was loaded correctly #13 I only added a script to the package.json, the rest are new files, so hopefully there won't be any merge conflicts in the future.

The test runs automatically when you do npm publish or npm pack. The test works for me with Linux, if anybody wants to check, just run npm pack and see what happens.

@melloware
Copy link
Owner

This looks great!

@melloware melloware linked an issue Nov 23, 2021 that may be closed by this pull request
@melloware melloware merged commit c6272ab into melloware:main Nov 23, 2021
@melloware
Copy link
Owner

It fails on Windows with,,,

C:\dev\melloware-git\coloris-npm>npm pack

> @melloware/coloris@0.8.1 prepack
> gulp build ; npm run test-npm

[15:40:11] Requiring external module @babel/register
[15:40:12] Using gulpfile C:\dev\melloware-git\coloris-npm\gulpfile.babel.js
[15:40:12] Task never defined: ;
[15:40:12] To list available tasks, try running: gulp --tasks
npm ERR! code 1
npm ERR! path C:\dev\melloware-git\coloris-npm
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c gulp build ; npm run test-npm

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\XXXX\AppData\Local\npm-cache\_logs\2021-11-23T20_40_12_690Z-debug.log

@melloware
Copy link
Owner

OK if I change ; to & I get this now...

C:\dev\melloware-git\coloris-npm>npm pack

> @melloware/coloris@0.8.1 prepack
> gulp build & npm run test-npm

[15:46:29] Requiring external module @babel/register
[15:46:30] Using gulpfile C:\dev\melloware-git\coloris-npm\gulpfile.babel.js
[15:46:30] Starting 'build'...
[15:46:30] Starting 'minifyJS'...
[15:46:30] Starting 'minifyCSS'...
[15:46:30] Starting 'copySourceCSS'...
[15:46:30] Starting 'copySourceDts'...
[15:46:31] Finished 'copySourceCSS' after 611 ms
[15:46:31] Finished 'copySourceDts' after 611 ms
[15:46:31] Finished 'minifyCSS' after 614 ms
[15:46:31] Finished 'minifyJS' after 931 ms
[15:46:31] Finished 'build' after 933 ms

> @melloware/coloris@0.8.1 test-npm
> node test-npm/run-tests.js

Error while running test Error: spawnSync npm ENOENT
    at Object.spawnSync (node:internal/child_process:1083:20)
    at Object.spawnSync (node:child_process:812:24)
    at exports.spawnSimple (C:\dev\melloware-git\coloris-npm\test-npm\helper.js:19:32)
    at Object.module.exports.main (C:\dev\melloware-git\coloris-npm\test-npm\webpack-ts\run-test.js:11:9)
    at async main (C:\dev\melloware-git\coloris-npm\test-npm\run-tests.js:2:3) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawnSync npm',
  path: 'npm',
  spawnargs: [ 'install' ]
}
npm ERR! code 1
npm ERR! path C:\dev\melloware-git\coloris-npm
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c gulp build & npm run test-npm

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\XXXX\AppData\Local\npm-cache\_logs\2021-11-23T20_46_32_722Z-debug.log

@blutorange
Copy link
Collaborator Author

Hmm, I was hoping npm would be on your path when you can run the script, but it the error looks like it can't find the npm binary?

@melloware
Copy link
Owner

melloware commented Nov 23, 2021

its definitely on my path i can run these from anywhere...

C:\dev\melloware-git\coloris-npm>npm --version
8.1.3

C:\dev\melloware-git\coloris-npm>node --version
v16.13.0

@blutorange
Copy link
Collaborator Author

I found this nodejs/node#3675 (comment) (need to use npm.cmd instead of npm) and there also seem to be some npm packages for spawning npm like https://www.npmjs.com/package/spawn-npm Let me see if I can include this package

@blutorange
Copy link
Collaborator Author

or better question: does it work for you when you change

image

to

  await spawnSimple("npm.cmd", ["install"], __dirname);
  await spawnSimple("npm.cmd", ["run", "build"], __dirname);

?

@melloware
Copy link
Owner

Yes it does!

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

Successfully merging this pull request may close these issues.

[Vue] init is not a function
2 participants