-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,722 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
USER_HOME=/home/chihab | ||
NGX_VERSION=IGNORED_SINCE_SET_IN_ENV_LOCAL | ||
NGX_USER_HOME=$USER_HOME | ||
NGX_BRANCH=main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
NGX_VERSION=12.0.0 | ||
NGX_BRANCH=test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const jestConfig = { | ||
preset: "jest-preset-angular/presets/defaults-esm", | ||
setupFilesAfterEnv: ["<rootDir>/setup-jest.ts"], | ||
testMatch: ["<rootDir>/src/app/**/*.(spec|jest).ts"], | ||
cache: false, | ||
moduleNameMapper: { | ||
"^rxjs(/operators$)?$": | ||
"<rootDir>/node_modules/rxjs/dist/bundles/rxjs.umd.js", | ||
tslib: "<rootDir>/node_modules/tslib/tslib.es6.mjs", | ||
}, | ||
transform: { | ||
"^.+\\.(ts)$": [ | ||
"@dotenv-run/jest-angular", | ||
{ | ||
useESM: true, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default jestConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { env } from '@dotenv-run/core'; | ||
env({ root: '../../..', files: ['.env', '.env.app'] }); | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
|
||
import '@angular/localize/init'; | ||
import { TextEncoder } from 'util'; | ||
Object.defineProperty(window, 'TextEncoder', { | ||
writable: true, | ||
value: TextEncoder, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
|
||
describe('AppComponent', () => { | ||
let component: AppComponent; | ||
let fixture: ComponentFixture<AppComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [AppComponent], | ||
}).compileComponents(); | ||
fixture = TestBed.createComponent(AppComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create the app', () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app).toBeTruthy(); | ||
it('should create the app 2', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it(`should have the 'Hello world' title`, () => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.componentInstance; | ||
expect(app.title).toEqual('Hello world'); | ||
expect(component.title).toEqual('Hello world'); | ||
expect(component.branch).toEqual('test'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<p>hello works!</p> |
23 changes: 23 additions & 0 deletions
23
examples/apps/ng-app-cli/src/app/hello/hello.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HelloComponent } from './hello.component'; | ||
|
||
describe('HelloComponent', () => { | ||
let component: HelloComponent; | ||
let fixture: ComponentFixture<HelloComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [HelloComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(HelloComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-hello', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './hello.component.html', | ||
styleUrl: './hello.component.css' | ||
}) | ||
export class HelloComponent { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
/* To learn more about this file see: https://angular.io/config/tsconfig. */ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./out-tsc/spec", | ||
"types": ["jasmine", "@angular/localize"] | ||
"types": ["jasmine", "@angular/localize"], | ||
"esModuleInterop": true, | ||
"module": "es2022" | ||
}, | ||
"include": ["src/**/*.spec.ts", "src/polyfills.ts", "src/**/*.d.ts"] | ||
"include": [ | ||
"src/**/*.spec.ts", | ||
"src/**/*.jest.ts", | ||
"src/polyfills.ts", | ||
"src/**/*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NgJestTransformer } from "jest-preset-angular/build/ng-jest-transformer.js"; | ||
export default { | ||
createTransformer: (tsJestConfig) => { | ||
const ngT = new NgJestTransformer(tsJestConfig); | ||
return { | ||
process: (src, filename, config, options) => { | ||
if (/.ts$/.test(filename)) { | ||
src = ` | ||
import.meta.env = process.env; | ||
${src} | ||
`; | ||
} | ||
return ngT.process(src, filename, config, options); | ||
}, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@dotenv-run/jest-angular", | ||
"version": "0.1.0", | ||
"description": "Run Jest with Angular CLI environment variables", | ||
"homepage": "https://github.com/chihab/dotenv-run", | ||
"sideEffects": true, | ||
"files": [ | ||
"index.mjs", | ||
"README.md" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./index.mjs", | ||
"require": "./index.mjs" | ||
} | ||
}, | ||
"keywords": [ | ||
"dotenv", | ||
"run", | ||
"cli" | ||
], | ||
"peerDependencies": { | ||
"jest-preset-angular": "^14.0.0" | ||
}, | ||
"devDependencies": { | ||
"jest-preset-angular": "14.0.0" | ||
}, | ||
"author": "Chihab Otmani <chihab@gmail.com>", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@dotenv-run/jest", | ||
"version": "0.1.0", | ||
"description": "Run Jest with import.meta.env", | ||
"homepage": "https://github.com/chihab/dotenv-run", | ||
"main": "src/jest-env.mjs", | ||
"module": "src/jest-env.mjs", | ||
"files": [ | ||
"src", | ||
"README.md" | ||
], | ||
"keywords": [ | ||
"dotenv", | ||
"run" | ||
], | ||
"author": "Chihab Otmani <chihab@gmail.com>", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
createTransformer: () => { | ||
return { | ||
process: (src, filename) => { | ||
if (/.ts$/.test(filename)) { | ||
src = ` | ||
import.meta.env = process.env; | ||
${src} | ||
`; | ||
} | ||
return { code: src }; | ||
}, | ||
}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.