Skip to content

Commit 15b8921

Browse files
committed
feat: update unit tests to latest
Removed htmlhint (way outdated, caused node depreccation warning). May add markuplint in future. Removed less. Low usage, and very easy for users to add to their project if they need. Removed browser-do+jasmine, browser-do+mocha, since almost nobody uses browser-do. Just provide jest/vitest for unit tests.
1 parent 25d44a2 commit 15b8921

30 files changed

+88
-375
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ This will cause `npx` to download the `makes` tool, along with the `aurelia` sca
1616

1717
## Development
1818

19-
This scaffolding skeleton is in the early stage, not quite ready for adding features. We want to keep feature set manageable as Aurelia 2 is constantly evolving.
20-
2119
There are some tests for this skeleton, setup in package.json. (totally not required by makes)
2220

2321
## Unit tests
Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
1-
// @if mocha
2-
import { expect } from 'chai';
3-
// @endif
41
// @if vitest
52
import { describe, it, expect } from 'vitest';
63
// @endif
7-
// @if shadow-dom
8-
import { CustomElement } from 'aurelia';
9-
// @endif
10-
import { render } from './helper';
114
import { MyApp } from '../src/my-app';
5+
import { createFixture } from '@aurelia/testing';
6+
// @if jest
7+
import { bootstrapTestEnvironment } from './setup';
8+
9+
beforeAll(bootstrapTestEnvironment);
10+
// @endif
1211

1312
describe('my-app', () => {
1413
it('should render message', async () => {
15-
const node = (await render('<my-app></my-app>', MyApp)).firstElementChild;
16-
// @if shadow-dom
17-
// In Shadow DOM open mode, shadowRoot is also accessible through DOM API
18-
// node.shadowRoot
19-
// But only Aurelia API can access shadowRoot in both open and closed mode.
20-
const shadowRoot = CustomElement.for(node).shadowRoot;
21-
// @if babel
22-
const text = shadowRoot.textContent;
23-
// @endif
24-
// @if typescript
25-
const text = (shadowRoot as Node).textContent;
26-
// @endif
27-
// @endif
28-
// @if !shadow-dom
29-
const text = node.textContent;
30-
// @endif
31-
// @if jasmine || jest || vitest
32-
expect(text.trim()).toBe('Hello World!');
33-
// @endif
34-
// @if mocha
35-
expect(text.trim()).to.equal('Hello World!');
36-
// @endif
14+
const { assertText, startPromise, stop } = createFixture(
15+
'<my-app></my-app>',
16+
{},
17+
[MyApp],
18+
);
19+
20+
try {
21+
await startPromise;
22+
assertText('Hello World!', { compact: true });
23+
} finally {
24+
await stop(true);
25+
}
3726
});
3827
});

common/.eslintrc.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@
2222
},
2323

2424
"env": {
25-
"es6": true,
25+
"es2024": true,
2626
"browser": true,
2727
"node": true,
28-
// @if jasmine
29-
"jasmine": true,
30-
// @endif
31-
// @if mocha
32-
"mocha": true,
33-
// @endif
28+
"globalThis": true,
3429
// @if jest
3530
"jest": true,
3631
// @endif

common/.htmlhintrc__skip-if-exists

Lines changed: 0 additions & 12 deletions
This file was deleted.

common/.stylelintrc.json__skip-if-exists

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
// @if sass
77
"stylelint-config-standard-scss",
88
// @endif
9-
// @if less
10-
"stylelint-config-standard-less",
11-
// @endif
129
// @if css-module
1310
"stylelint-config-css-modules"
1411
// @endif

common/README.md__skip-if-exists

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,4 @@ Run unit tests in watch mode.
9393

9494
npm run test:watch
9595

96-
// @if jasmine || mocha
97-
Unit tests run in browser through [browser-do](https://github.com/3cp/browser-do). Please check scripts in `package.json` for more details.
98-
99-
By default, browser-do shuts down browser after tests. To keep browser window open for inspection, pass additional argument `-k` or `--keep-open`.
100-
101-
npm run build:test && browser-do -k /* @if jasmine */--jasmine/* @endif *//* @if mocha */--mocha/* @endif */ --browser chrome < dist/entry.bundle.js
102-
103-
// @if webpack
104-
Unit tests in watch mode is executed through stand webpack watch mode and the help of [webpack-shell-plugin-next](https://github.com/s00d/webpack-shell-plugin-next).
105-
// @endif
106-
// @if dumber
107-
Unit tests in watch mode is executed through standard `gulp.watch` with the help of [gulp-run](https://github.com/MrBoolean/gulp-run).
108-
// @endif
109-
// @endif
11096
// @endif

common/package.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,16 @@
2828
"devDependencies": {
2929
"eslint": "^8.57.0",
3030
"@aurelia/testing": /* @if latest */"latest"/* @endif *//* @if dev */"dev"/* @endif */,
31-
"htmlhint": "^1.1.4",
3231
"stylelint": "^16.3.1",
3332
// @if css
3433
"stylelint-config-standard": "^36.0.0",
3534
// @endif
36-
// @if less
37-
"stylelint-config-standard-less": "^3.0.1",
38-
// @endif
3935
// @if sass
4036
"stylelint-config-standard-scss": "^13.1.0",
4137
// @endif
4238
// @if css-module
4339
"stylelint-config-css-modules": "^4.4.0",
4440
// @endif
45-
// @if jasmine || mocha
46-
"browser-do": "^4.1.0",
47-
// @endif
4841
},
4942
"scripts": {
5043
"lint:js": "eslint src/* @if !no-unit-tests */ test/* @endif *//* @if playwright */ e2e/* @endif *//* @if typescript */ --ext .js,.ts/* @endif */",
@@ -54,17 +47,7 @@
5447
// @if sass
5548
"lint:css": "stylelint \"src/**/*.scss\"",
5649
// @endif
57-
// @if less
58-
"lint:css": "stylelint \"src/**/*.less\"",
59-
// @endif
60-
"lint:html": "htmlhint -c .htmlhintrc src",
61-
"lint": "npm run lint:js && npm run lint:html && npm run lint:css",
62-
// @if jest
50+
"lint": "npm run lint:js && npm run lint:css",
6351
"pretest": "npm run lint",
64-
// @endif
65-
// @if jasmine || mocha
66-
"test": "npm run test:headless",
67-
"pretest": "npm run lint && npm run build:test",
68-
// @endif
6952
}
7053
}

common/src/main.ext__if_app

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { MyApp } from './my-app';
1313
// They are for sharedStyles in shadowDOM.
1414
// However, css files imported in other js/ts files are processed by style-loader.
1515
// @endif
16-
// import shared from './shared./* @if css */css/* @endif *//* @if less */less/* @endif *//* @if sass */scss/* @endif */';
16+
// import shared from './shared./* @if css */css/* @endif *//* @if sass */scss/* @endif */';
1717
// @endif
1818

1919
Aurelia

common/src/resource.d.ts__if_typescript

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ declare module '*.module.css' {
1515
const value: Record<string, string>;
1616
export default value;
1717
}
18-
// @if less
19-
declare module '*.module.less' {
20-
const value: Record<string, string>;
21-
export default value;
22-
}
23-
// @endif
2418
// @if sass
2519
declare module '*.module.scss' {
2620
const value: Record<string, string>;
@@ -30,9 +24,6 @@ declare module '*.module.scss' {
3024
// @endif
3125
// @if !css-module
3226
declare module '*.css';
33-
// @if less
34-
declare module '*.less';
35-
// @endif
3627
// @if sass
3728
declare module '*.scss';
3829
// @endif

common/test__if_not_no-unit-tests/helper.ext

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)