10 Commits
v2.0.0 ... main

Author SHA1 Message Date
Hugo Alliaume
2dd8302c75 2.1.0 2025-07-05 13:38:16 +02:00
Hugo Alliaume
17420a4b7c feature #10 Deprecate the package (Kocal)
This PR was merged into the main branch.

Discussion
----------

Deprecate the package

I don't think there is any interest in _maintaining_ it anymore. Because of Jest and Babel, installing ``@symfony`/stimulus-testing` installs [**~500 subdependencies**](https://npmgraph.js.org/?q=%40symfony%2Fstimulus-testing), which is totally unacceptable, since the added-value of this package is only these two functions:
```js
export function mountDOM(html = '') {
    const div = document.createElement('div');
    div.innerHTML = html;
    document.body.appendChild(div);

    return div;
}

export function clearDOM() {
    document.body.innerHTML = '';
}
```

It's like a Composer package, but all its dependencies being shadowed and not removable by the final user.

Removing it from `@symfony`/ux, where we don't use Jest and Babel but Vitest, allowed us to remove ~400 useless Node.js dev dependencies: https://github.com/symfony/ux/pull/2879

The package is still experimental, and I suggest to deprecate this package. I've added migration steps for people being stuck with it, even if I think we, Symfony, are maybe the only ones to use it:

https://github.com/user-attachments/assets/86a21c37-8560-43dc-bec9-0043875831ea

We can observe:
1. it always had ~1k downloads per week this last year,
2. more recently we had ~21k downloads per week, and I believe that's correlated to my last two-months work on UX
3. and since a few days, it started to drop again (currently at 8k downloads for the last full week), when I removed it from UX

Commits
-------

07d2209 Deprecate the package
2025-07-05 13:36:56 +02:00
Hugo Alliaume
07d2209dd5 Deprecate the package 2025-07-02 18:08:01 +02:00
Ryan Weaver
7194dc04c9 minor #8 fix readme import name (a.baron)
This PR was merged into the main branch.

Discussion
----------

fix readme import name

This merge request is created after this conversation : https://github.com/symfony/stimulus-testing/issues/6

Commits
-------

9588a2b fix readme import name
2023-10-03 12:02:58 -04:00
Ryan Weaver
25bca2c62e minor #9 fix readme babel preset env (a.baron)
This PR was merged into the main branch.

Discussion
----------

fix readme babel preset env

This merge request is created after this conversation : https://github.com/symfony/stimulus-testing/issues/7

Commits
-------

0438da3 fix readme babel preset env
2023-10-03 12:02:37 -04:00
a.baron
0438da3771 fix readme babel preset env 2023-10-03 11:40:54 +02:00
a.baron
9588a2bde0 fix readme import name 2023-10-03 11:36:29 +02:00
Titouan Galopin
edd246b564 Tagging 2.0.1 2021-12-09 15:50:35 +01:00
Titouan Galopin
cc5151bde1 bug #5 Fix usage of 2.0 with Jest (tgalopin)
This PR was merged into the main branch.

Discussion
----------

Fix usage of 2.0 with Jest

Commits
-------

b79342d Fix usage of 2.0 with Jest
2021-12-09 15:50:10 +01:00
Titouan Galopin
b79342d6c4 Fix usage of 2.0 with Jest 2021-12-09 15:49:32 +01:00
3 changed files with 48 additions and 7 deletions

View File

@@ -1,5 +1,48 @@
# Symfony UX Stimulus testing
> [!WARNING]
> **Deprecated**: This package is deprecated and will not receive any further updates.
Because this package only provides very small helpers to help write tests for Stimulus controllers, and is tightly coupled with [Jest](https://jestjs.io/), [jsdom](https://github.com/jsdom/jsdom) and [Testing Library](https://testing-library.com/) dependencies, we can no longer recommend it.
In 2025, we cannot force developers to install Jest (and [~270 sub-dependencies](https://npmgraph.js.org/?q=jest) including [Babel](https://babeljs.io/)) and the like, since [many test runners exist](https://npmtrends.com/ava-vs-japa-vs-jasmine-vs-jest-vs-karma-vs-mocha-vs-tap-vs-vitest), and many of them are more modern and much faster, like [Vitest](https://vitest.dev/).
We want to give you the choice to use the best tools for your needs, and not force you to use what we suggested in the past.
To migrate from `@symfony/stimulus-testing`, you can follow these steps:
1. Install the dev dependencies `@testing-library/jest-dom @testing-library/dom`;
you may also want to install `mutationobserver-shim regenerator-runtime` if you still have
legacy code or _architecture_.
2. In the file `assets/test/setup.js`, replace imports:
```diff
-import '@symfony/stimulus-testing/setup';
+import '@testing-library/jest-dom';
```
3. Create the file `assets/test/stimulus-helpers.js` with the following content:
```js
export function mountDOM(html = '') {
const div = document.createElement('div');
div.innerHTML = html;
document.body.appendChild(div);
return div;
}
export function clearDOM() {
document.body.innerHTML = '';
}
```
4. In your tests files, replace imports for `mountDOM` and `clearDOM`:
```diff
// assets/test/controllers/hello_controller.test.js
-import { clearDOM, mountDOM } from '@symfony/stimulus-testing';
+import { clearDOM, mountDOM } from '../stimulus-helpers';
```
5. And finally, remove the `@symfony/stimulus-testing` dependency from your project.
---
Symfony UX Stimulus testing is a low-level package to help write tests for Stimulus controllers
in applications and reusable packages.
@@ -28,7 +71,7 @@ To start using Symfony UX Testing, you first need to configure a testing environ
2. Create a `assets/test/setup.js` file to initialize Symfony UX Testing:
```js
import '@symfony/ux-testing/setup';
import '@symfony/stimulus-testing/setup';
```
3. Create a `assets/jest.config.js` file for Jest configuration:
@@ -45,7 +88,7 @@ module.exports = {
```json
{
"presets": ["@babel/env"],
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
```

View File

@@ -1,7 +1,7 @@
{
"name": "@symfony/stimulus-testing",
"description": "@testing-library integration for Symfony UX",
"version": "2.0.0",
"version": "2.1.0",
"main": "src/index.js",
"license": "MIT",
"author": "Titouan Galopin <galopintitouan@gmail.com>",

View File

@@ -9,7 +9,7 @@
'use strict';
const mountDOM = (htmlString = '') => {
module.exports.mountDOM = (htmlString = '') => {
const div = document.createElement('div');
div.innerHTML = htmlString;
document.body.appendChild(div);
@@ -17,8 +17,6 @@ const mountDOM = (htmlString = '') => {
return div;
};
const clearDOM = () => {
module.exports.clearDOM = () => {
document.body.innerHTML = '';
};
export { clearDOM, mountDOM };