Skip to content

Commit

Permalink
Add test case for embroider with embertemplate-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoviv committed Mar 12, 2024
1 parent 5ce8e6a commit 762b029
Show file tree
Hide file tree
Showing 40 changed files with 13,099 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`app coverage generation > generates coverage with embroider and template imports 1`] = `
{
"app/app.js": {
"branches": {
"covered": 0,
"pct": 100,
"skipped": 0,
"total": 0,
},
"functions": {
"covered": 0,
"pct": 100,
"skipped": 0,
"total": 0,
},
"lines": {
"covered": 4,
"pct": 100,
"skipped": 0,
"total": 4,
},
"statements": {
"covered": 4,
"pct": 100,
"skipped": 0,
"total": 4,
},
},
"app/components/bar.gjs": {
"branches": {
"covered": 0,
"pct": 100,
"skipped": 0,
"total": 0,
},
"functions": {
"covered": 1,
"pct": 100,
"skipped": 0,
"total": 1,
},
"lines": {
"covered": 3,
"pct": 100,
"skipped": 0,
"total": 3,
},
"statements": {
"covered": 3,
"pct": 100,
"skipped": 0,
"total": 3,
},
},
"app/router.js": {
"branches": {
"covered": 0,
"pct": 100,
"skipped": 0,
"total": 0,
},
"functions": {
"covered": 0,
"pct": 0,
"skipped": 0,
"total": 1,
},
"lines": {
"covered": 1,
"pct": 33.33,
"skipped": 0,
"total": 3,
},
"statements": {
"covered": 1,
"pct": 33.33,
"skipped": 0,
"total": 3,
},
},
"total": {
"branches": {
"covered": 0,
"pct": 100,
"skipped": 0,
"total": 0,
},
"branchesTrue": {
"covered": 0,
"pct": 100,
"skipped": 0,
"total": 0,
},
"functions": {
"covered": 1,
"pct": 50,
"skipped": 0,
"total": 2,
},
"lines": {
"covered": 8,
"pct": 80,
"skipped": 0,
"total": 10,
},
"statements": {
"covered": 8,
"pct": 80,
"skipped": 0,
"total": 10,
},
},
}
`;
16 changes: 8 additions & 8 deletions test-packages/gjs-gts-ignore-template-plugin-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe('gjs-gts-ignore-template-plugin', () => {
const example = processor.process(`import { on } from '@ember/modifier';
let counter = 0;
function bar() {
counter++;
console.log(counter);
}
<template>
<button {{on "click" bar}}>
increment
Expand All @@ -31,14 +31,14 @@ describe('gjs-gts-ignore-template-plugin', () => {
const example = processor.process(`import { on } from '@ember/modifier';
let counter = 0;
function bar() {
const template = ()=>{};
template();
counter++;
console.log(counter);
}
<template>
<button {{on "click" bar}}>
increment
Expand All @@ -54,12 +54,12 @@ describe('gjs-gts-ignore-template-plugin', () => {
const example = processor.process(`import { on } from '@ember/modifier';
let counter = 0;
function bar() {
counter++;
console.log(counter);
}
<template>
<button {{on "click" bar}}>
increment
Expand All @@ -75,12 +75,12 @@ describe('gjs-gts-ignore-template-plugin', () => {
const example = processor.process(`import { on } from '@ember/modifier';
let counter = 0;
function bar() {
counter++;
console.log(counter);
}
<template>
<button {{on "click" bar}}>
increment
Expand Down
25 changes: 25 additions & 0 deletions test-packages/my-embroider-app-template-imports-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

import { execa } from 'execa';
import setupTestDir, { assertCoverageExists, assertFileIsNotEmpty } from './utils.mjs';
import { describe, it } from 'vitest';

const APP_DIR = 'my-embroider-app-template-imports';

describe('app coverage generation', function () {
const env = { COVERAGE: 'true' };

it(`generates coverage with embroider and template imports`, async function () {
let buildPath = await setupTestDir(APP_DIR, env, {});

// Embroider tries to reuse .embroider folder if present during builds.
// We need make sure previous test runs don't affect newer test runs, as the embroider/core
// version that generated the folder would be different to the one trying to use it, which can lead to unexpected behaviour.
// await execa('rm', ['-rf', '.embroider'], { cwd: buildPath, env });
await execa('rm', ['-rf', '.embroider'], { cwd: buildPath, env });

await execa('npx', ['ember','test', '--test-port=0'], { cwd: buildPath, env });

await assertCoverageExists(`${buildPath}/coverage`);
});
});
19 changes: 19 additions & 0 deletions test-packages/my-embroider-app-template-imports/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
7 changes: 7 additions & 0 deletions test-packages/my-embroider-app-template-imports/.ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
/**
Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript
rather than JavaScript by default, when a TypeScript version of a given blueprint is available.
*/
"isTypeScriptProject": false
}
13 changes: 13 additions & 0 deletions test-packages/my-embroider-app-template-imports/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# unconventional js
/blueprints/*/files/

# compiled output
/dist/

# misc
/coverage/
!.*
.*/

# ember-try
/.node_modules.ember-try/
56 changes: 56 additions & 0 deletions test-packages/my-embroider-app-template-imports/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';

module.exports = {
root: true,
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
requireConfigFile: false,
babelOptions: {
plugins: [
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
],
},
},
plugins: ['ember'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:prettier/recommended',
],
env: {
browser: true,
},
rules: {},
overrides: [
// node files
{
files: [
'./.eslintrc.js',
'./.prettierrc.js',
'./.stylelintrc.js',
'./.template-lintrc.js',
'./ember-cli-build.js',
'./testem.js',
'./blueprints/*/index.js',
'./config/**/*.js',
'./lib/*/index.js',
'./server/**/*.js',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
extends: ['plugin:n/recommended'],
},
{
// test files
files: ['tests/**/*-test.{js,ts}'],
extends: ['plugin:qunit/recommended'],
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches:
- main
- master
pull_request: {}

concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Install Dependencies
run: npm ci
- name: Lint
run: npm run lint

test:
name: "Test"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
- name: Install Dependencies
run: npm ci
- name: Run Tests
run: npm test
25 changes: 25 additions & 0 deletions test-packages/my-embroider-app-template-imports/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# compiled output
/dist/
/declarations/

# dependencies
/node_modules/

# misc
/.env*
/.pnp*
/.eslintcache
/coverage/
/npm-debug.log*
/testem.log
/yarn-error.log

# ember-try
/.node_modules.ember-try/
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try

# broccoli-debug
/DEBUG/
13 changes: 13 additions & 0 deletions test-packages/my-embroider-app-template-imports/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# unconventional js
/blueprints/*/files/

# compiled output
/dist/

# misc
/coverage/
!.*
.*/

# ember-try
/.node_modules.ember-try/

0 comments on commit 762b029

Please sign in to comment.