Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a separate TypeScript project for the test scenarios #2057

Open
wants to merge 4 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ module.exports = {
},
},
{
files: ['test-packages/**/*.[jt]s', 'tests/scenarios/**/*.{js,ts}'],
files: ['test-packages/**/*.[jt]s'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
{
files: ['tests/scenarios/**/*.ts'],
parserOptions: {
project: './tests/scenarios/tsconfig.json',
},
rules: {
'import/no-extraneous-dependencies': 'off',
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"scripts": {
"clean": "git clean -x -f",
"compile": "tsc",
"compile": "tsc -b",
"dev": "tsc -b --watch",
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
Expand All @@ -15,7 +15,7 @@
"lint:prettier": "prettier . -c",
"lint:prettier:fix": "prettier . -w",
"lint:router-types": "cd packages/router && pnpm lint:types",
"prepare": "tsc && pnpm build-v2-addons",
"prepare": "tsc -b && pnpm build-v2-addons",
"build-v2-addons": "concurrently 'pnpm:build-v2-addons:*'",
"build-v2-addons:router": "cd packages/router && pnpm build",
"test": "cd tests/scenarios && pnpm test"
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@types/resolve": "^1.20.0",
"@types/semver": "^7.3.5",
"@types/tmp": "^0.1.0",
"@types/qunit": "^2.11.1",
"fixturify": "^2.1.1",
"tmp": "^0.1.0",
"typescript": "^5.1.6"
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import makeDebug from 'debug';
import { format } from 'util';

// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type qunit from 'qunit';

const todo = makeDebug('embroider:todo');
const unsupported = makeDebug('embroider:unsupported');
const debug = makeDebug('embroider:debug');
Expand Down
18 changes: 11 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test-packages/support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/babel__traverse": "^7.18.5",
"@types/fs-extra": "^9.0.12",
"@types/lodash": "^4.14.170",
"@types/node": "^10.5.2"
"@types/node": "^10.5.2",
"@types/qunit": "^2.11.1"
}
}
17 changes: 9 additions & 8 deletions tests/scenarios/compat-plugin-hints-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { join } from 'path';
import QUnit from 'qunit';
const { module: Qmodule, test } = QUnit;

export function samplePlugin() {
return { visitor: {} };
}

appScenarios
.map('compat-plugin-hints', app => {
app.files['ember-cli-build.js'] = `
app.mergeFiles({
'sample-plugin.js': `module.exports.samplePlugin = function samplePlugin() {
return { visitor: {} };
}`,
'ember-cli-build.js': `
'use strict';
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
Expand All @@ -25,7 +25,7 @@ appScenarios
babel: {
plugins: [
// deliberately non-serializable form
require("${__filename.replace(/\\/g, '/').replace(/\.ts$/, '.js')}").samplePlugin
require(__dirname + '/sample-plugin.js').samplePlugin
]
}
});
Expand All @@ -38,13 +38,14 @@ appScenarios
],
pluginHints: [
{
resolve: ["${__filename.replace(/\\/g, '/').replace(/\.ts$/, '.js')}"],
resolve: [__dirname + '/sample-plugin.js'],
useMethod: 'samplePlugin',
},
],
});
};
`;
`,
});
})
.forEachScenario(scenario => {
Qmodule(scenario.name, function (hooks) {
Expand Down
8 changes: 4 additions & 4 deletions tests/scenarios/router-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let routerApp = tsAppScenarios.map('router', project => {

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const { maybeEmbroider } = require('@embroider/test-setup');

module.exports = function (defaults) {
let app = new EmberApp(defaults, {
'ember-cli-babel': {
Expand All @@ -30,7 +30,7 @@ let routerApp = tsAppScenarios.map('router', project => {
}
}
});

return maybeEmbroider(app, {
staticAddonTestSupportTrees: true,
staticAddonTrees: true,
Expand Down Expand Up @@ -219,7 +219,7 @@ let routerApp = tsAppScenarios.map('router', project => {
);
});
});

`,
},
},
Expand All @@ -234,7 +234,7 @@ routerApp.forEachScenario(scenario => {
});

test(`type checks`, async function (assert) {
let result = await app.execute('pnpm tsc');
let result = await app.execute('pnpm tsc -b');
assert.equal(result.exitCode, 0, result.output);
});
});
Expand Down
8 changes: 8 additions & 0 deletions tests/scenarios/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig-base",
"include": ["*.ts"],
"compilerOptions": {
"rootDir": ".",
"outDir": "./build"
}
}
2 changes: 1 addition & 1 deletion tests/scenarios/typescript-app-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ typescriptApp.forEachScenario(scenario => {
});

test(`check types`, async function (assert) {
let result = await app.execute(`pnpm tsc`);
let result = await app.execute(`pnpm tsc -b`);
assert.equal(result.exitCode, 0, result.output);
});
});
Expand Down
18 changes: 18 additions & 0 deletions tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"declaration": true,
"typeRoots": ["types", "node_modules/@types"],
"esModuleInterop": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"sourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"allowUnreachableCode": false,
"strict": true,
"skipLibCheck": true,
"useUnknownInCatchVariables": false,
},
}
20 changes: 2 additions & 18 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
{
"extends": "./tsconfig-base",
"include": [
"./packages/*/src/**/*.ts",
"./packages/*/tests/**/*.ts",
"./test-packages/support/**/*.ts",
"./test-packages/release/src/**/*.ts",
"./tests/scenarios/**/*.ts"
"./test-packages/release/src/**/*.ts"
],
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"declaration": true,
"typeRoots": ["types", "node_modules/@types"],
"esModuleInterop": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"sourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"allowUnreachableCode": false,
"strict": true,
"skipLibCheck": true,
"useUnknownInCatchVariables": false,
},
"exclude": [
"node_modules",
"packages/*/tmp",
Expand Down
Loading