Skip to content

Setup automatic releases #3

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

Closed
kentcdodds opened this issue Apr 15, 2018 · 14 comments
Closed

Setup automatic releases #3

kentcdodds opened this issue Apr 15, 2018 · 14 comments

Comments

@kentcdodds
Copy link
Member

In the project, run:

npm i -g semantic-release-cli
semantic-release-cli setup

Follow the prompts and you'll have automatic releases set up. See http://kcd.im/write-oss for more info.

@larrybotha
Copy link

@antsmartian I'm happy to make a PR for this - bunch of features that are here on Github but aren't published to NPM.

@antsmartian
Copy link
Collaborator

@larrybotha Welcome. But almost all the latest codebase and its features are published to NPM.

@larrybotha
Copy link

@antsmartian ye, there are a couple things missing like rerender and debug.

Will get on this in the coming days.

@larrybotha
Copy link

awwww bup bup... I can't do this without being a collaborator on the repo owner, and access on npm :/

@jseto
Copy link

jseto commented Apr 2, 2019

Looks like still not fixed

@antsmartian
Copy link
Collaborator

@jseto Yes, feel free to raise a PR. (sorry I'm not finding enough time for this)

@jseto
Copy link

jseto commented Apr 2, 2019

To my understanding, it is not a matter of a PR since the GIT repository is correct. It is on the NPM side as @larrybotha said

@larrybotha
Copy link

I've just replaced preact-testing-library with @testing-library/react in a Preact 8.x project with +-120 test suites containing +-1000 individual tests - I had no major issues. Only thing was having to add a few await wait()s here and there for rendering

Looks like we can safely use @testing-library going forward

@fondberg
Copy link

@larrybotha what do you mean with "safely use @testing-libray going forward"?

@larrybotha
Copy link

@fondberg there seems to be no need to rely on preact-testing-library anymore - you may be able to replace your imports with @testing-library/react without any major changes to your tests.

@fondberg
Copy link

@larrybotha
Copy link

@fondberg Kent's using fireEventAsync there - React updates state synchronously, while Preact updates state asynchronously (as far as I learnt from testingjavascript.com); Kent's awaiting the re-render in the component once the button is clicked.

fireEventAsync essentially wraps await wait() with the event

Check out my notes here:
https://github.com/larrybotha/testing-javascript/tree/master/07-use-dom-testing-library-to-test-any-js-framework#2-use-dom-testing-library-with-preact
and annotations for fireEventAsync here: https://github.com/larrybotha/testing-javascript/blob/99b74fd77bf112882734c4e4bc266b22dc9988b4/07-use-dom-testing-library-to-test-any-js-framework/__tests__/helpers/fire-event-async.js

In React they're unnecessary, but in Preact they seem necessary for now :)

I haven't yet tinkered with Preact X, however.

@larrybotha
Copy link

larrybotha commented Jul 23, 2019

A note to anyone coming across this and having trouble with @testing-library/react; v8.0.6 introduced detection of React's act from react-dom/test-utils which you likely won't have in a Preact project.

Because @testing-library/react detects act one needs to point Jest somewhere to handle the react-dom/test-utils import, otherwise Jest will throw on file not found.

Preact X solution

preact/test-utils was added to Preact X in Feb 2019, so one could map react-dom/test-utils to Preact's test utils if using a version of Preact X released since then, and benefit from Preact's implementation of act:

// jest.config

// ...

	moduleNameMapper: {
		// ...
		'^react-dom/test-utils$': 'preact/test-utils',
		// ...
	},

// ...

Note: This is untested

Preact 8.x.x solution

One can add a configuration to moduleNameMapper in their Jest config pointing to a file exporting an empty module:

// config/tests/react-dom-test-utils.js
/**
 * export an empty object, i.e. `act` is undefined
 */
module.exports = {};
// jest.config

// ...

	moduleNameMapper: {
		// ...
		'^react-dom/test-utils$': 'path/to/custom/react-dom-test-utils.js'),
		// ...
	},

// ...

Confirmed this works with Preact 8.4.2.

@mihar-22
Copy link
Contributor

Closing issue since we migrated to the testing-library, releases are now automated via semantic-release.

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

No branches or pull requests

6 participants