Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
Update the test runner config to support async/await in tests. (#1068)
Browse files Browse the repository at this point in the history
DEV

Allows use of async/await in tests. I updated one test to show what that would look like. Admittedly it makes that test inconsistent with the other tests if the file so I can drop that if preferred.
  • Loading branch information
tafsiri authored and dsmilkov committed Jun 1, 2018
1 parent 6c35fb1 commit d001ce5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
9 changes: 2 additions & 7 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ module.exports = function(config) {
},
karmaTypescriptConfig: {
tsconfig: 'tsconfig.json',
compilerOptions: {
module: 'commonjs',
sourceMap: true
}
compilerOptions: {module: 'commonjs', sourceMap: true}
},
reporters: ['progress', 'karma-typescript'],
browsers: ['Chrome', 'Firefox'],
Expand Down Expand Up @@ -57,8 +54,6 @@ module.exports = function(config) {
flags: ['--blacklist-accelerated-compositing', '--blacklist-webgl']
}
},
client: {
args: ['--grep', config.grep || '']
}
client: {args: ['--grep', config.grep || '']}
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@types/node": "~9.6.0",
"@types/seedrandom": "~2.4.27",
"clang-format": "~1.2.2",
"jasmine-core": "~2.6.4",
"jasmine-core": "~3.1.0",
"karma": "~1.7.0",
"karma-browserstack-launcher": "~1.3.0",
"karma-chrome-launcher": "~2.2.0",
Expand Down
26 changes: 8 additions & 18 deletions src/io/local_storage_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,15 @@ describeWithFlags('LocalStorage', CPU_ENVS, () => {
});
});

it('Save-load round trip succeeds', done => {
it('Save-load round trip succeeds', async () => {
const handler1 = tf.io.getSaveHandlers('localstorage://FooModel')[0];
handler1.save(artifacts1)
.then(saveResult => {
const handler2 = tf.io.getLoadHandlers('localstorage://FooModel')[0];
handler2.load()
.then(loaded => {
expect(loaded.modelTopology).toEqual(modelTopology1);
expect(loaded.weightSpecs).toEqual(weightSpecs1);
expect(loaded.weightData).toEqual(weightData1);
done();
})
.catch(err => {
console.error(err.stack);
});
})
.catch(err => {
console.error(err.stack);
});

await handler1.save(artifacts1);
const handler2 = tf.io.getLoadHandlers('localstorage://FooModel')[0];
const loaded = await handler2.load();
expect(loaded.modelTopology).toEqual(modelTopology1);
expect(loaded.weightSpecs).toEqual(weightSpecs1);
expect(loaded.weightData).toEqual(weightData1);
});

it('Loading nonexistent model fails.', done => {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1656,9 +1656,9 @@ istanbul@0.4.5, istanbul@^0.4.0:
which "^1.1.1"
wordwrap "^1.0.0"

jasmine-core@~2.6.4:
version "2.6.4"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.6.4.tgz#dec926cd0a9fa287fb6db5c755fa487e74cecac5"
jasmine-core@~3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.1.0.tgz#a4785e135d5df65024dfc9224953df585bd2766c"

js-tokens@^3.0.2:
version "3.0.2"
Expand Down

0 comments on commit d001ce5

Please sign in to comment.