Removing dist/ & testing against Stimulus 3

This commit is contained in:
Ryan Weaver
2021-09-27 15:28:09 -04:00
committed by Titouan Galopin
parent 12edab3d80
commit 3c7697ace8
8 changed files with 15 additions and 56 deletions

View File

@@ -1,4 +1,3 @@
{
"presets": ["@babel/env"],
"plugins": ["@babel/plugin-proposal-class-properties"]
"presets": ["@babel/env"]
}

View File

@@ -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

View File

@@ -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
View File

@@ -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;

View File

@@ -2,18 +2,14 @@
"name": "@symfony/stimulus-testing",
"description": "@testing-library integration for Symfony UX",
"version": "1.1.0",
"main": "dist/index.js",
"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"
]
}

View File

@@ -1 +1 @@
require('./dist/setup.js');
require('./src/setup.js');

View File

@@ -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');

View File

@@ -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 {