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

Fix-karma #1157

Closed
wants to merge 8 commits into from
Closed

Fix-karma #1157

wants to merge 8 commits into from

Conversation

nopeless
Copy link
Contributor

@nopeless nopeless commented Feb 5, 2023

Karma has been fixed

Make sure chrome and firefox are on your path. If you would not like to edit your path, make a simple script that sets CHROME_BIN and FIREFOX_BIN
@nopeless
Copy link
Contributor Author

nopeless commented Feb 5, 2023

#1129

@hipstersmoothie
Copy link
Collaborator

Could you try to remove all the browserify modules? I think there is a webpack-karma that might be better. Working on fixing CI right now for PRs

@nopeless
Copy link
Contributor Author

nopeless commented Feb 5, 2023

Could you try to remove all the browserify modules? I think there is a webpack-karma that might be better. Working on fixing CI right now for PRs

Sounds good.

@hipstersmoothie
Copy link
Collaborator

Here is where to turn the tests back on https://github.com/jimp-dev/jimp/blob/master/.github/workflows/build.yml#L69

@nopeless
Copy link
Contributor Author

nopeless commented Feb 5, 2023

@hipstersmoothie are we going to change browser testing framework in the TS release/next branch?

@hipstersmoothie
Copy link
Collaborator

I think keeping the ability to run the tests in the browser is a good idea.

I think karma is kinda old and we could replace it with this and playwright and get something better

Since I want to test in browser mocha will probably stay but I'm working on switching the assertion library from should to expect.

@hipstersmoothie
Copy link
Collaborator

The TS refactor shouldn't effect any of this

@hipstersmoothie
Copy link
Collaborator

Well expect doesn't work in browser </3

@nopeless
Copy link
Contributor Author

nopeless commented Feb 5, 2023

The TS refactor shouldn't effect any of this

yes but point is why not change testing framework when changing code as well

@nopeless
Copy link
Contributor Author

nopeless commented Feb 5, 2023

@hipstersmoothie Moving to webpack is causing issues with package/test-utils as apparantly Jimp had some kind of hack for loading tests

@hipstersmoothie
Copy link
Collaborator

Id try the newer tool before any further getting karma working.

If it makes it simpler you can also assume for the browser tests that jimp has already been bundles and exists in packages/jimp/browser/lib

@nopeless
Copy link
Contributor Author

nopeless commented Feb 5, 2023

@hipstersmoothie As some pointed out, we still have to maintain it for some time. We should still use Karma for the JS version of Jimp

@nopeless
Copy link
Contributor Author

nopeless commented Feb 5, 2023

@hipstersmoothie With that being said, even if we go to playwright I belive I would still have to debug this getTestDir in test-utils

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

Fixes #1129

@nopeless nopeless marked this pull request as draft February 6, 2023 00:10
@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

Issue found. esmodules don't have a prototype

Resorting to .default should be the fix

Edit 2: Preserving legacy behavior with es modules

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

image
Another reason why I advocate for a full rewrite. This is not maintainable behavior

@hipstersmoothie
Copy link
Collaborator

@nopeless I may have a PR that makes this easier

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

If you are talking about #1163, it doesn't fix the webpack issue. The conversion from CJS to ESM breaks tests as well

@hipstersmoothie
Copy link
Collaborator

#1163

@hipstersmoothie
Copy link
Collaborator

What/how are you web packing? The library itself already bundles fine we should be able to use that bundle to run tests with in a browser.

#1157 (comment)

Could you file an issue for this and propose what you think it should be?

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

import { Jimp, mkJGD } from "@jimp/test-utils";

describe("Compare image difference", () => {
  let imgs = [
    Jimp.read(mkJGD("2222", "4444", "6666", "8888")),

@hipstersmoothie It seems that the Jimp here is the esmodule Jimp itself not Jimp class. That is what's causing the issue

@hipstersmoothie
Copy link
Collaborator

Ahhh I see

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

Ahhh I see

I currently have a hack where on jgd-wrapper I unwrap Jimp to Jimp.default when Jimp is esmodule but I believe it is ultimately up to you to decide how you want to resolve this issue

@hipstersmoothie
Copy link
Collaborator

Ok so if you're trying to get karma to still work I think we should stop that

The steps I see for running the tests in browser:

  1. Install this tool https://modern-web.dev/docs/test-runner/overview/
  2. Configure it to match our tests
  3. probably will need to use https://modern-web.dev/docs/dev-server/plugins/esbuild/
  4. configure it to use playwright

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

Ok so if you're trying to get karma to still work I think we should stop that

The steps I see for running the tests in browser:

  1. Install this tool https://modern-web.dev/docs/test-runner/overview/
  2. Configure it to match our tests
  3. probably will need to use https://modern-web.dev/docs/dev-server/plugins/esbuild/
  4. configure it to use playwright

I am almost certain that this isn't a Karma issue. (Unless you are talking about the esoteric loading system that is in place for karma at the moment. That is certainly an issue that this PR will fix)

If, however, configuring esbuild and an alternative testing system implies removing the current one, I am definitely up for that. For now, I don't think we need more changes other than using webpack.

@hipstersmoothie
Copy link
Collaborator

Yeah I def wanna remove karma entirely. mocha + expect are here to stay but karma I want gone

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

Yeah I def wanna remove karma entirely. mocha + expect are here to stay but karma I want gone

Well, we can do that in another PR. I want Karma at least running so it can run against other fixes while the test migration is in progress

@hipstersmoothie
Copy link
Collaborator

Sounds like a good plan!

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

Apparantly the newest build updated yarn.lock for packages as well since I had updated test-utils

With that being said, why is test-utils in src in the first place

@nopeless nopeless marked this pull request as ready for review February 6, 2023 01:20
@hipstersmoothie
Copy link
Collaborator

@nopeless you can update the lock file just by running yarn

@hipstersmoothie
Copy link
Collaborator

Organizing packages like this is pretty standard for JS monorepos

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

The lock file is already updated. I just found it weird that tests loaders are coupled with the versioning. I understand why tests are part of the versions but the loaders should be minimal and not versioned; A gotcha moment for me

@nopeless
Copy link
Contributor Author

nopeless commented Feb 6, 2023

@hipstersmoothie I see wht you mean

@hipstersmoothie hipstersmoothie deleted the branch jimp-dev:master February 6, 2023 05:42
@hipstersmoothie
Copy link
Collaborator

whoops this closed cause I renamed master

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.

2 participants