mirror of
https://github.com/symfony/stimulus-testing.git
synced 2026-03-24 09:02:06 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78f5aef61c | ||
|
|
40c5c8bcbf | ||
|
|
3c7697ace8 | ||
|
|
12edab3d80 |
3
.babelrc
3
.babelrc
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"presets": ["@babel/env"],
|
||||
"plugins": ["@babel/plugin-proposal-class-properties"]
|
||||
"presets": ["@babel/env"]
|
||||
}
|
||||
|
||||
4
.github/workflows/test.yaml
vendored
4
.github/workflows/test.yaml
vendored
@@ -9,8 +9,8 @@ jobs:
|
||||
- uses: actions/checkout@master
|
||||
- name: Prettier
|
||||
run: |
|
||||
yarn global add prettier@^2.2.0
|
||||
~/.yarn/bin/prettier --check src/**/*.js --config .prettierrc.json
|
||||
yarn add prettier@^2.2.0
|
||||
yarn run prettier --check {src,test}/**/*.js --config .prettierrc.json
|
||||
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
Symfony UX Stimulus testing is a low-level package to help write tests for Stimulus controllers
|
||||
in applications and reusable packages.
|
||||
|
||||
**If you are developing a project with Symfony Flex, you should probably use the ux-test-pack
|
||||
instead**. The pack includes this package and configures it automatically in your application.
|
||||
|
||||
Symfony UX Stimulus testing is currently considered **experimental**.
|
||||
|
||||
## Installation
|
||||
@@ -50,12 +47,13 @@ module.exports = {
|
||||
{
|
||||
"presets": ["@babel/env"],
|
||||
"plugins": ["@babel/plugin-proposal-class-properties"]
|
||||
}
|
||||
```
|
||||
|
||||
5. Finally, create your first test, for instance `hello_controller.test.js`:
|
||||
|
||||
```js
|
||||
import { Application } from 'stimulus';
|
||||
import { Application } from '@hotwired/stimulus';
|
||||
import { clearDOM, mountDOM } from '@symfony/stimulus-testing';
|
||||
import HelloController from '../controllers/hello_controller.js';
|
||||
|
||||
|
||||
30
dist/index.js
vendored
30
dist/index.js
vendored
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.mountDOM = exports.clearDOM = void 0;
|
||||
|
||||
var mountDOM = function mountDOM() {
|
||||
var htmlString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = htmlString;
|
||||
document.body.appendChild(div);
|
||||
return div;
|
||||
};
|
||||
|
||||
exports.mountDOM = mountDOM;
|
||||
|
||||
var clearDOM = function clearDOM() {
|
||||
document.body.innerHTML = '';
|
||||
};
|
||||
|
||||
exports.clearDOM = clearDOM;
|
||||
15
package.json
15
package.json
@@ -1,19 +1,15 @@
|
||||
{
|
||||
"name": "@symfony/stimulus-testing",
|
||||
"description": "@testing-library integration for Symfony UX",
|
||||
"version": "1.1.0",
|
||||
"main": "dist/index.js",
|
||||
"version": "2.0.0",
|
||||
"main": "src/index.js",
|
||||
"license": "MIT",
|
||||
"author": "Titouan Galopin <galopintitouan@gmail.com>",
|
||||
"engines": {
|
||||
"node": "^10.13.0 || >=12.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src -d dist",
|
||||
"test": "babel src -d dist && jest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"stimulus": "^2.0"
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@testing-library/dom": "^7.28.1",
|
||||
@@ -25,11 +21,9 @@
|
||||
"regenerator-runtime": "^0.13.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.12.1",
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
||||
"@babel/preset-env": "^7.12.7",
|
||||
"stimulus": "^2.0.0"
|
||||
"@hotwired/stimulus": "^3.0.0"
|
||||
},
|
||||
"jest": {
|
||||
"testRegex": "test/.*\\.test.js",
|
||||
@@ -39,7 +33,6 @@
|
||||
},
|
||||
"files": [
|
||||
"src/",
|
||||
"dist/",
|
||||
"setup.js"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
require("mutationobserver-shim");
|
||||
|
||||
require("regenerator-runtime/runtime.js");
|
||||
|
||||
require("@testing-library/jest-dom");
|
||||
require('mutationobserver-shim');
|
||||
require('regenerator-runtime/runtime.js');
|
||||
require('@testing-library/jest-dom');
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { Application, Controller } from 'stimulus';
|
||||
import { Application, Controller } from '@hotwired/stimulus';
|
||||
import { getByTestId, waitFor } from '@testing-library/dom';
|
||||
import { clearDOM, mountDOM } from '../dist/index';
|
||||
import { clearDOM, mountDOM } from '../src/index';
|
||||
|
||||
// Controller used to check the actual controller was properly booted
|
||||
class AppController extends Controller {
|
||||
|
||||
Reference in New Issue
Block a user