Skip to content

Commit

Permalink
feat: update unit tests to latest
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
3cp committed Aug 10, 2024
1 parent 25d44a2 commit 4cc6a57
Show file tree
Hide file tree
Showing 30 changed files with 89 additions and 377 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ This will cause `npx` to download the `makes` tool, along with the `aurelia` sca

## Development

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.

There are some tests for this skeleton, setup in package.json. (totally not required by makes)

## Unit tests
Expand Down
49 changes: 19 additions & 30 deletions app-min/test__if_not_no-unit-tests/my-app.spec.ext
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
// @if mocha
import { expect } from 'chai';
// @endif
// @if vitest
import { describe, it, expect } from 'vitest';
// @endif
// @if shadow-dom
import { CustomElement } from 'aurelia';
import { describe, it } from 'vitest';
// @endif
import { render } from './helper';
import { MyApp } from '../src/my-app';
import { createFixture } from '@aurelia/testing';
// @if jest
import { bootstrapTestEnvironment } from './setup';

beforeAll(bootstrapTestEnvironment);
// @endif

describe('my-app', () => {
it('should render message', async () => {
const node = (await render('<my-app></my-app>', MyApp)).firstElementChild;
// @if shadow-dom
// In Shadow DOM open mode, shadowRoot is also accessible through DOM API
// node.shadowRoot
// But only Aurelia API can access shadowRoot in both open and closed mode.
const shadowRoot = CustomElement.for(node).shadowRoot;
// @if babel
const text = shadowRoot.textContent;
// @endif
// @if typescript
const text = (shadowRoot as Node).textContent;
// @endif
// @endif
// @if !shadow-dom
const text = node.textContent;
// @endif
// @if jasmine || jest || vitest
expect(text.trim()).toBe('Hello World!');
// @endif
// @if mocha
expect(text.trim()).to.equal('Hello World!');
// @endif
const { assertText, startPromise, stop } = createFixture(
'<my-app></my-app>',
{},
[MyApp],
);

try {
await startPromise;
assertText('Hello World!', { compact: true });
} finally {
await stop(true);
}
});
});
8 changes: 1 addition & 7 deletions common/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@
},

"env": {
"es6": true,
"es2024": true,
"browser": true,
"node": true,
// @if jasmine
"jasmine": true,
// @endif
// @if mocha
"mocha": true,
// @endif
// @if jest
"jest": true,
// @endif
Expand Down
12 changes: 0 additions & 12 deletions common/.htmlhintrc__skip-if-exists

This file was deleted.

3 changes: 0 additions & 3 deletions common/.stylelintrc.json__skip-if-exists
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// @if sass
"stylelint-config-standard-scss",
// @endif
// @if less
"stylelint-config-standard-less",
// @endif
// @if css-module
"stylelint-config-css-modules"
// @endif
Expand Down
14 changes: 0 additions & 14 deletions common/README.md__skip-if-exists
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,4 @@ Run unit tests in watch mode.

npm run test:watch

// @if jasmine || mocha
Unit tests run in browser through [browser-do](https://github.com/3cp/browser-do). Please check scripts in `package.json` for more details.

By default, browser-do shuts down browser after tests. To keep browser window open for inspection, pass additional argument `-k` or `--keep-open`.

npm run build:test && browser-do -k /* @if jasmine */--jasmine/* @endif *//* @if mocha */--mocha/* @endif */ --browser chrome < dist/entry.bundle.js

// @if webpack
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).
// @endif
// @if dumber
Unit tests in watch mode is executed through standard `gulp.watch` with the help of [gulp-run](https://github.com/MrBoolean/gulp-run).
// @endif
// @endif
// @endif
19 changes: 1 addition & 18 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,16 @@
"devDependencies": {
"eslint": "^8.57.0",
"@aurelia/testing": /* @if latest */"latest"/* @endif *//* @if dev */"dev"/* @endif */,
"htmlhint": "^1.1.4",
"stylelint": "^16.3.1",
// @if css
"stylelint-config-standard": "^36.0.0",
// @endif
// @if less
"stylelint-config-standard-less": "^3.0.1",
// @endif
// @if sass
"stylelint-config-standard-scss": "^13.1.0",
// @endif
// @if css-module
"stylelint-config-css-modules": "^4.4.0",
// @endif
// @if jasmine || mocha
"browser-do": "^4.1.0",
// @endif
},
"scripts": {
"lint:js": "eslint src/* @if !no-unit-tests */ test/* @endif *//* @if playwright */ e2e/* @endif *//* @if typescript */ --ext .js,.ts/* @endif */",
Expand All @@ -54,17 +47,7 @@
// @if sass
"lint:css": "stylelint \"src/**/*.scss\"",
// @endif
// @if less
"lint:css": "stylelint \"src/**/*.less\"",
// @endif
"lint:html": "htmlhint -c .htmlhintrc src",
"lint": "npm run lint:js && npm run lint:html && npm run lint:css",
// @if jest
"lint": "npm run lint:js && npm run lint:css",
"pretest": "npm run lint",
// @endif
// @if jasmine || mocha
"test": "npm run test:headless",
"pretest": "npm run lint && npm run build:test",
// @endif
}
}
2 changes: 1 addition & 1 deletion common/src/main.ext__if_app
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { MyApp } from './my-app';
// They are for sharedStyles in shadowDOM.
// However, css files imported in other js/ts files are processed by style-loader.
// @endif
// import shared from './shared./* @if css */css/* @endif *//* @if less */less/* @endif *//* @if sass */scss/* @endif */';
// import shared from './shared./* @if css */css/* @endif *//* @if sass */scss/* @endif */';
// @endif

Aurelia
Expand Down
9 changes: 0 additions & 9 deletions common/src/resource.d.ts__if_typescript
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ declare module '*.module.css' {
const value: Record<string, string>;
export default value;
}
// @if less
declare module '*.module.less' {
const value: Record<string, string>;
export default value;
}
// @endif
// @if sass
declare module '*.module.scss' {
const value: Record<string, string>;
Expand All @@ -30,9 +24,6 @@ declare module '*.module.scss' {
// @endif
// @if !css-module
declare module '*.css';
// @if less
declare module '*.less';
// @endif
// @if sass
declare module '*.scss';
// @endif
Expand Down
11 changes: 0 additions & 11 deletions common/test__if_not_no-unit-tests/helper.ext

This file was deleted.

16 changes: 16 additions & 0 deletions common/test__if_not_no-unit-tests/setup.ext
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BrowserPlatform } from '@aurelia/platform-browser';
import { setPlatform } from '@aurelia/testing';

// Sets up the Aurelia environment for testing
// @if vitest
const platform = new BrowserPlatform(window);
setPlatform(platform);
BrowserPlatform.set(globalThis, platform);
// @endif
// @if jest
export function bootstrapTestEnvironment() {
const platform = new BrowserPlatform(window);
setPlatform(platform);
BrowserPlatform.set(globalThis, platform);
}
// @endif
9 changes: 0 additions & 9 deletions common/test__if_not_no-unit-tests/setup.ext__if_ava

This file was deleted.

Loading

0 comments on commit 4cc6a57

Please sign in to comment.