Skip to content

Commit

Permalink
change dir
Browse files Browse the repository at this point in the history
  • Loading branch information
tinayuangao committed Jan 6, 2017
1 parent 19061b3 commit 8a1bc82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions e2e/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {browser} from 'protractor';

export class Screenshot {
id: string;
dir: string = '/tmp/angular-material2-build/logs/';//__dirname;

/** The filename used to store the screenshot. */
get filename(): string {
Expand All @@ -28,27 +29,27 @@ export class Screenshot {

/** The full path to the screenshot */
get fullPath(): string {
return path.resolve(__dirname, '..', 'screenshots', this.filename);
return path.resolve(this.dir, 'screenshots', this.filename);
}

constructor(id: string) {
console.log(`constructor with input ${id}`);
console.error(`constructor with input ${id}`);
this.id = `${jasmine.getEnv().currentSpec} ${id}`;
browser.takeScreenshot();//.then(png => this.storeScreenshot(png));
console.log(`constructor ${id} is called`);
browser.takeScreenshot().then(png => this.storeScreenshot(png));
console.error(`constructor ${id} is called`);
}

/** Replaces the existing screenshot with the newly generated one. */
storeScreenshot(png: any) {
console.log(`store screenshot for ${this.id}`);
var dir = path.resolve(__dirname, '..', 'screenshots');
console.error(`store screenshot for ${this.id}`);
var dir = path.resolve(this.dir, 'screenshots');
if (!fs.existsSync(dir)) {
console.log(`making dir for ${dir}`);
console.error(`making dir for ${dir}`);
fs.mkdirSync(dir, 0x744);
}
console.log(`write to file ${this.fullPath}`);
console.error(`write to file ${this.fullPath}`);
fs.writeFileSync(this.fullPath, png, {encoding: 'base64' });
console.log(`wwrite is done`);
console.error(`wwrite is done`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if (process.env['TRAVIS']) {
// Because Protractor runs selenium instances concurrently in the CI and each instance
// will create a bloat of logs we don't want to show any info messages.
// Until protractor#1451 is solved, manually disable all info messages.
require('protractor/built/logger').Logger.prototype.info = () => {};
// require('protractor/built/logger').Logger.prototype.info = () => {};
}


Expand Down

0 comments on commit 8a1bc82

Please sign in to comment.