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

Split the seed tests for iOS and Android, test the demo unit tests. #2

Merged
merged 1 commit into from
Jun 9, 2017
Merged
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
3 changes: 2 additions & 1 deletion seed-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"rimraf": "^2.6.1"
},
"scripts": {
"test": "jasmine --config=jasmine.config.json"
"test.android": "ANDROID=true jasmine --config=jasmine.config.json",
"test.ios": "IOS=true jasmine --config=jasmine.config.json"
},
"dependencies": {}
}
16 changes: 16 additions & 0 deletions seed-tests/postclone.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,20 @@ describe('postclone', function() {
expect(fs.realpathSync(demoPluginPackageJson)).toEqual(fs.realpathSync(srcPluginPackageJson));
done();
});

it('should prepare a working demo with passing tests', function(done) {
var testsCommand = "cd " + constants.SEED_COPY_LOCATION + "/src && npm run test";
testsCommand += testUtils.isAndroid() ? ".android" : ".ios";
exec(testsCommand, function(error, stdout, stderr) {
if (testUtils.isAndroid()) {
// currently npm link does not work with tns test on android
// it this test fail we should assert that the tests are passing
expect(stderr).toContain("java.io.IOException: File already exists.");
} else {
expect(error).toBeNull();
}

done();
});
});
});
2 changes: 1 addition & 1 deletion seed-tests/tests.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ exports.SEED_COPY_LOCATION = "seed-copy";
exports.DEFAULT_PLUGIN_NAME = "nativescript-yourplugin";
exports.TEST_PLUGIN_NAME = "ThePlugin";
exports.TEST_GITHUB_USERNAME = "TheGitHubUser";
jasmine.DEFAULT_TIMEOUT_INTERVAL = 180000; // 180 secs
jasmine.DEFAULT_TIMEOUT_INTERVAL = 300000; // 5 mins
14 changes: 9 additions & 5 deletions seed-tests/tests.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,21 @@ exports.removeNpmLink = function removeNpmLink(packageName, callback) {
});
}

exports.isAndroid = function isAndroid() {
return !!!process.env.IOS;
}

function getPackageJsonPostcloneScript() {
var packageJsonFile = constants.SEED_COPY_LOCATION + "/src/package.json";
if (fs.lstatSync(packageJsonFile).isFile()) {

if (fs.lstatSync(packageJsonFile).isFile()) {
var packageJson = JSON.parse(fs.readFileSync(packageJsonFile, 'utf8'));
var packageJsonScripts = packageJson["scripts"];

if(packageJsonScripts && packageJsonScripts["postclone"]) {
if (packageJsonScripts && packageJsonScripts["postclone"]) {
return packageJsonScripts["postclone"];
};
}
}

return "";
return "";
}
12 changes: 6 additions & 6 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
},
"scripts": {
"tsc": "tsc -skipLibCheck",

"postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link ",
"test": "npm run tslint && cd ../demo && tns build ios && tns build android && tns test ios && tns test android",
"tslint": "cd ../ && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"",
"postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src && npm run plugin.link",
"test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch",
"test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch",
"tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\"",
"plugin.link": "npm link && cd ../demo && npm link nativescript-yourplugin && cd ../src",
"plugin.tscwatch": "npm run tsc -- -w",
"demo.ios": "cd ../demo && tns run ios --syncAllFiles",
"demo.android": "cd ../demo && tns run android --syncAllFiles"
"demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles"
},
"repository": {
"type": "git",
Expand Down